mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] stock_secondary_unit: Migration to 13.0
This commit is contained in:
committed by
Jesús Alan Ramos Rodríguez
parent
7ba30da3f9
commit
e415b946ca
@@ -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|
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
~~~~~~~~~~~
|
||||
@@ -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.
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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"
|
||||
@@ -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):
|
||||
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
0
stock_secondary_unit/report/report_deliveryslip.xml
Executable file → Normal file
0
stock_secondary_unit/report/report_deliveryslip.xml
Executable file → Normal file
@@ -367,7 +367,7 @@ ul.auto-toc {
|
||||
!! 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>
|
||||
@@ -400,7 +400,7 @@ other units with their conversion factor.</p>
|
||||
<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">
|
||||
@@ -417,6 +417,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<li>Carlos Dauden <<a class="reference external" href="mailto:carlos.dauden@tecnativa.com">carlos.dauden@tecnativa.com</a>></li>
|
||||
<li>Sergio Teruel <<a class="reference external" href="mailto:sergio.teruel@tecnativa.com">sergio.teruel@tecnativa.com</a>></li>
|
||||
<li>Kitti Upariphutthiphong <<a class="reference external" href="mailto:kittiu@ecosoft.co.th">kittiu@ecosoft.co.th</a>></li>
|
||||
<li>Pimolnat Suntian <<a class="reference external" href="mailto:pimolnats@ecosoft.co.th">pimolnats@ecosoft.co.th</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
@@ -426,7 +427,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<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>
|
||||
|
||||
@@ -68,12 +68,7 @@ class TestProductSecondaryUnit(SavepointCase):
|
||||
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(
|
||||
{
|
||||
@@ -95,7 +90,7 @@ class TestProductSecondaryUnit(SavepointCase):
|
||||
|
||||
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)
|
||||
|
||||
|
||||
10
stock_secondary_unit/views/product_views.xml
Executable file → Normal file
10
stock_secondary_unit/views/product_views.xml
Executable file → Normal file
@@ -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>
|
||||
|
||||
15
stock_secondary_unit/views/stock_move_views.xml
Executable file → Normal file
15
stock_secondary_unit/views/stock_move_views.xml
Executable file → Normal file
@@ -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
stock_secondary_unit/views/stock_picking_views.xml
Executable file → Normal file
6
stock_secondary_unit/views/stock_picking_views.xml
Executable file → Normal file
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user