Skip to content

Commit

Permalink
[MIG] migrate sale_order_secondary_unit from 12.0 to 13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBinsfeld committed Jan 15, 2020
1 parent 76625f3 commit 39c5775
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 121 deletions.
1 change: 1 addition & 0 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
product-attribute
10 changes: 5 additions & 5 deletions sale_order_secondary_unit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Sale Order Secondary Unit
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/12.0/sale_order_secondary_unit
:target: https://github.com/OCA/sale-workflow/tree/13.0/sale_order_secondary_unit
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_order_secondary_unit
:target: https://translation.odoo-community.org/projects/sale-workflow-13-0/sale-workflow-13-0-sale_order_secondary_unit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/12.0
:target: https://runbot.odoo-community.org/runbot/167/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -50,7 +50,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_secondary_unit%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_secondary_unit%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -82,6 +82,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/12.0/sale_order_secondary_unit>`_ project on GitHub.
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/13.0/sale_order_secondary_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
37 changes: 17 additions & 20 deletions sale_order_secondary_unit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
# Copyright 2018 Tecnativa - Carlos Dauden
# Copyright 2018-2020 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
'name': 'Sale Order Secondary Unit',
'summary': 'Sale product in a secondary unit',
'version': '12.0.1.0.0',
'development_status': 'Beta',
'category': 'Sale',
'website': 'https://github.com/OCA/sale-workflow',
'author': 'Tecnativa, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'application': False,
'installable': True,
'auto_install': True,
'depends': [
'sale',
'product_secondary_unit',
],
'data': [
'views/product_views.xml',
'views/sale_order_views.xml',
'report/sale_report_templates.xml',
"name": "Sale Order Secondary Unit",
"summary": "Sale product in a secondary unit",
"version": "13.0.1.0.0",
"development_status": "Beta",
"category": "Sale",
"website": "https://github.com/OCA/sale-workflow",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"auto_install": True,
"depends": ["sale", "product_secondary_unit"],
"data": [
"views/product_views.xml",
"views/sale_order_views.xml",
"report/sale_report_templates.xml",
],
}
1 change: 1 addition & 0 deletions sale_order_secondary_unit/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-15 13:25+0000\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: de\n"
Expand Down
9 changes: 5 additions & 4 deletions sale_order_secondary_unit/i18n/sale_order_secondary_unit.pot
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_secondary_unit
# * sale_order_secondary_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"POT-Creation-Date: 2020-01-15 13:25+0000\n"
"PO-Revision-Date: 2020-01-15 13:25+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -43,4 +45,3 @@ msgstr ""
#: model:ir.model.fields,field_description:sale_order_secondary_unit.field_sale_order_line__secondary_uom_id
msgid "Secondary uom"
msgstr ""

1 change: 1 addition & 0 deletions sale_order_secondary_unit/i18n/zh_CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-15 13:25+0000\n"
"Last-Translator: Tony Gu <tony@openerp.cn>\n"
"Language-Team: \n"
"Language: \n"
Expand Down
7 changes: 3 additions & 4 deletions sale_order_secondary_unit/models/product_template.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Copyright 2018 Tecnativa - Sergio Teruel
# Copyright 2018-2020 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class ProductTemplate(models.Model):
_inherit = 'product.template'
_inherit = "product.template"

sale_secondary_uom_id = fields.Many2one(
comodel_name='product.secondary.unit',
string='Default secondary unit for sales',
comodel_name="product.secondary.unit", string="Default secondary unit for sales"
)
61 changes: 36 additions & 25 deletions sale_order_secondary_unit/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,85 @@
# Copyright 2018 Tecnativa - Carlos Dauden
# Copyright 2018-2020 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo.addons import decimal_precision as dp
from odoo.tools.float_utils import float_compare, float_round


class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
_inherit = "sale.order.line"

secondary_uom_qty = fields.Float(
string='Secondary Qty',
digits=dp.get_precision('Product Unit of Measure'),
string="Secondary Qty", digits="Product Unit of Measure"
)
secondary_uom_id = fields.Many2one(
comodel_name='product.secondary.unit',
string='Secondary uom',
ondelete='restrict',
comodel_name="product.secondary.unit",
string="Secondary uom",
ondelete="restrict",
)

@api.onchange('secondary_uom_id', 'secondary_uom_qty')
@api.onchange("secondary_uom_id", "secondary_uom_qty")
def onchange_secondary_uom(self):
if not self.secondary_uom_id:
return
factor = self.secondary_uom_id.factor * self.product_uom.factor
qty = float_round(
self.secondary_uom_qty * factor,
precision_rounding=self.product_uom.rounding
precision_rounding=self.product_uom.rounding,
)
if float_compare(
self.product_uom_qty, qty,
precision_rounding=self.product_uom.rounding) != 0:
if (
float_compare(
self.product_uom_qty, qty, precision_rounding=self.product_uom.rounding
)
!= 0
):
self.product_uom_qty = qty

@api.onchange('product_uom_qty')
@api.onchange("product_uom_qty")
def onchange_secondary_unit_product_uom_qty(self):
if not self.secondary_uom_id:
return
factor = self.secondary_uom_id.factor * self.product_uom.factor
qty = float_round(
self.product_uom_qty / (factor or 1.0),
precision_rounding=self.secondary_uom_id.uom_id.rounding
precision_rounding=self.secondary_uom_id.uom_id.rounding,
)
if float_compare(
self.secondary_uom_qty, qty,
precision_rounding=self.secondary_uom_id.uom_id.rounding) != 0:
if (
float_compare(
self.secondary_uom_qty,
qty,
precision_rounding=self.secondary_uom_id.uom_id.rounding,
)
!= 0
):
self.secondary_uom_qty = qty

@api.onchange('product_uom')
@api.onchange("product_uom")
def onchange_product_uom_for_secondary(self):
if not self.secondary_uom_id:
return
factor = self.product_uom.factor * self.secondary_uom_id.factor
qty = float_round(
self.product_uom_qty / (factor or 1.0),
precision_rounding=self.product_uom.rounding
precision_rounding=self.product_uom.rounding,
)
if float_compare(
self.secondary_uom_qty, qty,
precision_rounding=self.product_uom.rounding) != 0:
if (
float_compare(
self.secondary_uom_qty,
qty,
precision_rounding=self.product_uom.rounding,
)
!= 0
):
self.secondary_uom_qty = qty

@api.onchange('product_id')
@api.onchange("product_id")
def product_id_change(self):
"""
If default sales secondary unit set on product, put on secondary
quantity 1 for being the default quantity. We override this method,
that is the one that sets by default 1 on the other quantity with that
purpose.
"""
res = super(SaleOrderLine, self).product_id_change()
res = super().product_id_change()
self.secondary_uom_id = self.product_id.sale_secondary_uom_id
if self.secondary_uom_id:
self.secondary_uom_qty = 1.0
Expand Down
8 changes: 4 additions & 4 deletions sale_order_secondary_unit/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>Sale Order Secondary Unit</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Sale Order Secondary Unit</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/sale-workflow/tree/12.0/sale_order_secondary_unit"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_order_secondary_unit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/167/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/sale-workflow/tree/13.0/sale_order_secondary_unit"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/sale-workflow-13-0/sale-workflow-13-0-sale_order_secondary_unit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/167/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of sale orders to allow sale products in
secondary unit of distinct category.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -399,7 +399,7 @@ <h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sale-workflow/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_secondary_unit%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_secondary_unit%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -425,7 +425,7 @@ <h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sale-workflow/tree/12.0/sale_order_secondary_unit">OCA/sale-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sale-workflow/tree/13.0/sale_order_secondary_unit">OCA/sale-workflow</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down

0 comments on commit 39c5775

Please sign in to comment.