Skip to content

Commit

Permalink
[MIG] stock_secondary_unit: Migration to 13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ps-tubtim committed Jan 27, 2020
1 parent 7277c34 commit 3f225f0
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 40 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
11 changes: 6 additions & 5 deletions stock_secondary_unit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Stock 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%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_secondary_unit
:target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_secondary_unit
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_secondary_unit
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_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/153/12.0
:target: https://runbot.odoo-community.org/runbot/153/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -51,7 +51,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/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/stock-logistics-warehouse/issues/new?body=module:%20stock_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/stock-logistics-warehouse/issues/new?body=module:%20stock_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 All @@ -69,6 +69,7 @@ Contributors
* Carlos Dauden <carlos.dauden@tecnativa.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>

Maintainers
~~~~~~~~~~~
Expand All @@ -83,6 +84,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/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_secondary_unit>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_secondary_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions stock_secondary_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{
"name": "Stock Secondary Unit",
"summary": "Get product quantities in a secondary unit",
"version": "13.0.1.0.2",
"development_status": "Beta",
"version": "13.0.1.0.0",
"development_status": "Production/Stable",
"category": "stock",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
19 changes: 11 additions & 8 deletions stock_secondary_unit/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from odoo import fields, models
from odoo.tools.float_utils import float_round

from odoo.addons import decimal_precision as dp


class StockProductSecondaryUnit(models.AbstractModel):
_name = "stock.product.secondary.unit"
Expand All @@ -13,15 +11,20 @@ class StockProductSecondaryUnit(models.AbstractModel):
secondary_unit_qty_available = fields.Float(
string="Quantity On Hand (2Unit)",
compute="_compute_secondary_unit_qty_available",
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
)

def _compute_secondary_unit_qty_available(self):
for product in self.filtered("stock_secondary_uom_id"):
qty = product.qty_available / (product.stock_secondary_uom_id.factor or 1.0)
product.secondary_unit_qty_available = float_round(
qty, precision_rounding=product.uom_id.rounding
)
for product in self:
if not product.stock_secondary_uom_id:
product.secondary_unit_qty_available = 0.0
else:
qty = product.qty_available / (
product.stock_secondary_uom_id.factor or 1.0
)
product.secondary_unit_qty_available = float_round(
qty, precision_rounding=product.uom_id.rounding
)


class ProductTemplate(models.Model):
Expand Down
6 changes: 2 additions & 4 deletions stock_secondary_unit/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from odoo import api, fields, models
from odoo.tools.float_utils import float_round

from odoo.addons import decimal_precision as dp


class StockSecondaryUnitMixin(models.AbstractModel):
_name = "stock.secondary.unit.mixin"
Expand All @@ -14,7 +12,7 @@ class StockSecondaryUnitMixin(models.AbstractModel):
comodel_name="product.secondary.unit", string="Second unit"
)
secondary_uom_qty = fields.Float(
string="Secondary Qty", digits=dp.get_precision("Product Unit of Measure")
string="Secondary Qty", digits="Product Unit of Measure"
)


Expand All @@ -23,7 +21,7 @@ class StockMove(models.Model):
_name = "stock.move"

def _merge_moves_fields(self):
res = super(StockMove, self)._merge_moves_fields()
res = super()._merge_moves_fields()
res["secondary_uom_qty"] = self[-1:].secondary_uom_qty
return res

Expand Down
1 change: 1 addition & 0 deletions stock_secondary_unit/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Carlos Dauden <carlos.dauden@tecnativa.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
Empty file modified stock_secondary_unit/report/report_deliveryslip.xml
100755 → 100644
Empty file.
7 changes: 4 additions & 3 deletions stock_secondary_unit/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Stock 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/stock-logistics-warehouse/tree/12.0/stock_secondary_unit"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_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/153/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/stock-logistics-warehouse/tree/13.0/stock_secondary_unit"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_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/153/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 stock module to allow define
other units with their conversion factor.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -400,7 +400,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/stock-logistics-warehouse/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/stock-logistics-warehouse/issues/new?body=module:%20stock_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/stock-logistics-warehouse/issues/new?body=module:%20stock_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 @@ -417,6 +417,7 @@ <h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<li>Carlos Dauden &lt;<a class="reference external" href="mailto:carlos.dauden&#64;tecnativa.com">carlos.dauden&#64;tecnativa.com</a>&gt;</li>
<li>Sergio Teruel &lt;<a class="reference external" href="mailto:sergio.teruel&#64;tecnativa.com">sergio.teruel&#64;tecnativa.com</a>&gt;</li>
<li>Kitti Upariphutthiphong &lt;<a class="reference external" href="mailto:kittiu&#64;ecosoft.co.th">kittiu&#64;ecosoft.co.th</a>&gt;</li>
<li>Pimolnat Suntian &lt;<a class="reference external" href="mailto:pimolnats&#64;ecosoft.co.th">pimolnats&#64;ecosoft.co.th</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -426,7 +427,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/stock-logistics-warehouse/tree/12.0/stock_secondary_unit">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_secondary_unit">OCA/stock-logistics-warehouse</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
9 changes: 2 additions & 7 deletions stock_secondary_unit/tests/test_stock_secondary_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ def setUpClass(cls):
secondary_unit = cls.env["product.secondary.unit"].search(
[("product_tmpl_id", "=", cls.product_template.id)], limit=1
)
cls.product_template.write(
{
"sale_secondary_uom_id": secondary_unit.id,
"stock_secondary_uom_id": secondary_unit.id,
}
)
cls.product_template.write({"stock_secondary_uom_id": secondary_unit.id})
StockQuant = cls.env["stock.quant"]
cls.quant_white = StockQuant.create(
{
Expand All @@ -95,7 +90,7 @@ def test_01_stock_secondary_unit_template(self):

def test_02_stock_secondary_unit_variant(self):
for variant in self.product_template.product_variant_ids.filtered(
"attribute_value_ids"
"product_template_attribute_value_ids"
):
self.assertEqual(variant.secondary_unit_qty_available, 20)

Expand Down
10 changes: 5 additions & 5 deletions stock_secondary_unit/views/product_views.xml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
ref="stock.product_form_view_procurement_button"/>
<field name="groups_id" eval="[(4, ref('uom.group_uom'))]"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='qty_available']/.." position="after">
<button class="oe_stat_button"
name="%(stock.product_open_quants)d"
icon="fa-building-o"
type="action" attrs="{'invisible':[('type', '!=', 'product')]}">
<xpath expr="//button[@name='action_open_quants']" position="after">
<button type="object"
name="action_open_quants"
attrs="{'invisible':[('type', '!=', 'product')]}"
class="oe_stat_button" icon="fa-building-o">
<div class="o_form_field o_stat_info">
<span class="o_stat_value"><field name="secondary_unit_qty_available" widget="statinfo" nolabel="1"/></span>
<span class="o_stat_text"><field name="stock_secondary_uom_id"/></span>
Expand Down
15 changes: 15 additions & 0 deletions stock_secondary_unit/views/stock_move_views.xml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@
</field>
</record>

<record id="view_stock_move_line_detailed_operation_tree" model="ir.ui.view">
<field name="name">stock.move.line.operations.tree</field>
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_stock_move_line_detailed_operation_tree"/>
<field name="groups_id" eval="[(4, ref('uom.group_uom'))]"/>
<field name="arch" type="xml">
<field name="product_uom_qty" position="before">
<field name="secondary_uom_qty"/>
<field name="secondary_uom_id"
domain="[('product_tmpl_id.product_variant_ids', 'in', [product_id])]"
options="{'no_create': True}"/>
</field>
</field>
</record>

</odoo>
6 changes: 0 additions & 6 deletions stock_secondary_unit/views/stock_picking_views.xml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
domain="[('product_tmpl_id.product_variant_ids', 'in', [product_id])]"
options="{'no_create': True}"/>
</xpath>
<xpath expr="//field[@name='move_line_ids_without_package']/tree/field[@name='product_uom_qty']" position="before">
<field name="secondary_uom_qty"/>
<field name="secondary_uom_id"
domain="[('product_tmpl_id.product_variant_ids', 'in', [product_id])]"
options="{'no_create': True}"/>
</xpath>
</field>
</record>

Expand Down

0 comments on commit 3f225f0

Please sign in to comment.