Skip to content

Commit

Permalink
[MIG] purchase_order_secondary_unit v11 to v12
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikul-Chaudhary committed Nov 19, 2019
1 parent 3da10ce commit b2763e5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions purchase_order_secondary_unit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Contributors
~~~~~~~~~~~~

* Sergio Teruel <[email protected]>
* Nikul Chaudhary <[email protected]>

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion purchase_order_secondary_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
'name': 'Purchase Order Secondary Unit',
'summary': 'Purchase product in a secondary unit',
'version': '11.0.1.0.0',
'version': '12.0.1.0.0',
'development_status': 'Beta',
'category': 'Purchase',
'website': 'https://github.com/OCA/purchase-workflow',
Expand Down
1 change: 1 addition & 0 deletions purchase_order_secondary_unit/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* Sergio Teruel <[email protected]>
* Nikul Chaudhary <[email protected]>
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Copyright 2018 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields
from odoo.tests import SavepointCase
from odoo.tests.common import SavepointCase, tagged


@tagged('post_install', '-at_install')
class TestPurchaseOrderSecondaryUnit(SavepointCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.product_uom_kg = cls.env.ref('product.product_uom_kgm')
cls.product_uom_gram = cls.env.ref('product.product_uom_gram')
cls.product_uom_unit = cls.env.ref('product.product_uom_unit')
cls.product_uom_kg = cls.env.ref('uom.product_uom_kgm')
cls.product_uom_gram = cls.env.ref('uom.product_uom_gram')
cls.product_uom_unit = cls.env.ref('uom.product_uom_unit')
cls.product = cls.env['product.product'].create({
'name': 'test',
'uom_id': cls.product_uom_kg.id,
Expand All @@ -31,9 +32,19 @@ def setUpClass(cls):
'name': 'test - partner',
'supplier': True,
})
po = cls.env['purchase.order'].new({
type_obj = cls.env['stock.picking.type']
company_id = cls.env.user.company_id.id
picking_type_id = type_obj.search([
('code', '=', 'incoming'),
('warehouse_id.company_id', '=', company_id)
], limit=1)
if not picking_type_id:
picking_type_id = cls.env.ref('stock.picking_type_in')
cls.purchase_order_obj = cls.env['purchase.order']
po_val = {
'partner_id': cls.partner.id,
'company_id': cls.env.user.company_id.id,
'picking_type_id': picking_type_id.id,
'order_line': [(0, 0, {
'name': cls.product.name,
'product_id': cls.product.id,
Expand All @@ -42,10 +53,10 @@ def setUpClass(cls):
'price_unit': 1000.00,
'date_planned': fields.Datetime.now(),
})],
})
}
po = cls.purchase_order_obj.new(po_val)
po.onchange_partner_id()
cls.order = cls.env['purchase.order'].create(
po._convert_to_write(po._cache))
cls.order = cls.purchase_order_obj.create(po_val)

def test_onchange_secondary_uom(self):
self.order.order_line.write({
Expand Down
2 changes: 1 addition & 1 deletion purchase_order_secondary_unit/views/product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<field name="name">Product template Secondary Unit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="groups_id" eval="[(4, ref('product.group_uom'))]"/>
<field name="groups_id" eval="[(4, ref('uom.group_uom'))]"/>
<field name="arch" type="xml">
<field name="uom_po_id" position="after">
<field name="purchase_secondary_uom_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<field name="name">Purchase Order Secondary Unit</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="groups_id" eval="[(4, ref('product.group_uom'))]"/>
<field name="groups_id" eval="[(4, ref('uom.group_uom'))]"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/form//field[@name='product_qty']" position="before">
<field name="secondary_uom_qty" class="oe_inline oe_no_button"
Expand Down

0 comments on commit b2763e5

Please sign in to comment.