[WIP][MIG][12.0] rma_purchase

This commit is contained in:
Murtuza Saleh
2019-03-20 18:21:15 +05:30
committed by Chanakya Soni
parent e7d1ef6ef9
commit 0d719f7a9a
10 changed files with 61 additions and 44 deletions

View File

@@ -39,6 +39,7 @@ Contributors
* Aaron Henriquez <ahenriquez@eficent.com> * Aaron Henriquez <ahenriquez@eficent.com>
* Lois Rilo <lois.rilo@eficent.com> * Lois Rilo <lois.rilo@eficent.com>
* Bhavesh Odedra <bodedra@opensourceintegrators.com> * Bhavesh Odedra <bodedra@opensourceintegrators.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
Maintainer Maintainer
---------- ----------

View File

@@ -3,7 +3,7 @@
{ {
'name': 'RMA Purchase', 'name': 'RMA Purchase',
'version': '11.0.1.0.0', 'version': '12.0.1.0.0',
'category': 'RMA', 'category': 'RMA',
'summary': 'RMA from PO', 'summary': 'RMA from PO',
'license': 'LGPL-3', 'license': 'LGPL-3',

View File

@@ -20,6 +20,7 @@ class RmaOrder(models.Model):
rec.po_count = po_count rec.po_count = po_count
@api.multi @api.multi
@api.depends('rma_line_ids')
def _compute_origin_po_count(self): def _compute_origin_po_count(self):
for rma in self: for rma in self:
purchases = rma.mapped( purchases = rma.mapped(

View File

@@ -78,6 +78,22 @@ class RmaOrderLine(models.Model):
readonly=True, compute='_compute_qty_purchase' readonly=True, compute='_compute_qty_purchase'
) )
@api.onchange('product_id', 'partner_id')
def _onchange_product_id(self):
"""Domain for purchase_order_line_id is computed here to make
it dynamic."""
res = super(RmaOrderLine, self)._onchange_product_id()
if not res.get('domain'):
res['domain'] = {}
domain = [
'|',
('order_id.partner_id', '=', self.partner_id.id),
('order_id.partner_id', 'child_of', self.partner_id.id)]
if self.product_id:
domain.append(('product_id', '=', self.product_id.id))
res['domain']['purchase_order_line_id'] = domain
return res
@api.onchange('operation_id') @api.onchange('operation_id')
def _onchange_operation_id(self): def _onchange_operation_id(self):
res = super(RmaOrderLine, self)._onchange_operation_id() res = super(RmaOrderLine, self)._onchange_operation_id()
@@ -122,8 +138,9 @@ class RmaOrderLine(models.Model):
'uom_id': line.product_uom.id, 'uom_id': line.product_uom.id,
'operation_id': operation.id, 'operation_id': operation.id,
'product_qty': line.product_qty, 'product_qty': line.product_qty,
'price_unit': line.currency_id.compute( 'price_unit': line.currency_id._convert(
line.price_unit, line.currency_id, round=False), line.price_unit, line.currency_id,
self.env.user.company_id, fields.Date.today(), round=False),
'in_route_id': operation.in_route_id.id or route, 'in_route_id': operation.in_route_id.id or route,
'out_route_id': operation.out_route_id.id or route, 'out_route_id': operation.out_route_id.id or route,
'receipt_policy': operation.receipt_policy, 'receipt_policy': operation.receipt_policy,

View File

@@ -1,65 +1,64 @@
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L. # Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from openerp.tests import common from odoo.tests import common
from openerp.fields import Datetime from odoo.fields import Datetime
class TestRmaPurchase(common.SingleTransactionCase): class TestRmaPurchase(common.TransactionCase):
@classmethod def setUp(self):
def setUpClass(cls): super(TestRmaPurchase, self).setUp()
super(TestRmaPurchase, cls).setUpClass()
cls.rma_obj = cls.env['rma.order'] self.rma_obj = self.env['rma.order']
cls.rma_line_obj = cls.env['rma.order.line'] self.rma_line_obj = self.env['rma.order.line']
cls.rma_op_obj = cls.env['rma.operation'] self.rma_op_obj = self.env['rma.operation']
cls.rma_add_purchase_wiz = cls.env['rma_add_purchase'] self.rma_add_purchase_wiz = self.env['rma_add_purchase']
cls.po_obj = cls.env['purchase.order'] self.po_obj = self.env['purchase.order']
cls.pol_obj = cls.env['purchase.order.line'] self.pol_obj = self.env['purchase.order.line']
cls.product_obj = cls.env['product.product'] self.product_obj = self.env['product.product']
cls.partner_obj = cls.env['res.partner'] self.partner_obj = self.env['res.partner']
cls.rma_route_cust = cls.env.ref('rma.route_rma_customer') self.rma_route_cust = self.env.ref('rma.route_rma_customer')
# Create supplier # Create supplier
supplier1 = cls.partner_obj.create({'name': 'Supplier 1'}) supplier1 = self.partner_obj.create({'name': 'Supplier 1'})
# Create products # Create products
cls.product_1 = cls.product_obj.create({ self.product_1 = self.product_obj.create({
'name': 'Test Product 1', 'name': 'Test Product 1',
'type': 'product', 'type': 'product',
}) })
cls.product_2 = cls.product_obj.create({ self.product_2 = self.product_obj.create({
'name': 'Test Product 2', 'name': 'Test Product 2',
'type': 'product', 'type': 'product',
}) })
# Create PO: # Create PO:
cls.po = cls.po_obj.create({ self.po = self.po_obj.create({
'partner_id': supplier1.id, 'partner_id': supplier1.id,
}) })
cls.pol_1 = cls.pol_obj.create({ self.pol_1 = self.pol_obj.create({
'name': cls.product_1.name, 'name': self.product_1.name,
'order_id': cls.po.id, 'order_id': self.po.id,
'product_id': cls.product_1.id, 'product_id': self.product_1.id,
'product_qty': 20.0, 'product_qty': 20.0,
'product_uom': cls.product_1.uom_id.id, 'product_uom': self.product_1.uom_id.id,
'price_unit': 100.0, 'price_unit': 100.0,
'date_planned': Datetime.now(), 'date_planned': Datetime.now(),
}) })
cls.pol_2 = cls.pol_obj.create({ self.pol_2 = self.pol_obj.create({
'name': cls.product_2.name, 'name': self.product_2.name,
'order_id': cls.po.id, 'order_id': self.po.id,
'product_id': cls.product_2.id, 'product_id': self.product_2.id,
'product_qty': 18.0, 'product_qty': 18.0,
'product_uom': cls.product_2.uom_id.id, 'product_uom': self.product_2.uom_id.id,
'price_unit': 150.0, 'price_unit': 150.0,
'date_planned': Datetime.now(), 'date_planned': Datetime.now(),
}) })
# Create RMA group: # Create RMA group:
cls.rma_group = cls.rma_obj.create({ self.rma_group = self.rma_obj.create({
'partner_id': supplier1.id, 'partner_id': supplier1.id,
'type': 'supplier', 'type': 'supplier',
}) })

View File

@@ -14,8 +14,6 @@
<field name="po_count" widget="statinfo" <field name="po_count" widget="statinfo"
string="Purchase Orders"/> string="Purchase Orders"/>
</button> </button>
</div>
<div name='button_box' position="inside">
<button type="object" <button type="object"
name="action_view_origin_purchase_order" name="action_view_origin_purchase_order"
class="oe_stat_button" class="oe_stat_button"

View File

@@ -70,8 +70,9 @@ class RmaAddPurchase(models.TransientModel):
'uom_id': line.product_uom.id, 'uom_id': line.product_uom.id,
'operation_id': operation.id, 'operation_id': operation.id,
'product_qty': line.product_qty, 'product_qty': line.product_qty,
'price_unit': line.currency_id.compute( 'price_unit': line.currency_id._convert(
line.price_unit, line.currency_id, round=False), line.price_unit, line.currency_id,
self.env.user.company_id, fields.Date.today(), round=False),
'rma_id': self.rma_id.id, 'rma_id': self.rma_id.id,
'in_route_id': operation.in_route_id.id or route, 'in_route_id': operation.in_route_id.id or route,
'out_route_id': operation.out_route_id.id or route, 'out_route_id': operation.out_route_id.id or route,

View File

@@ -29,7 +29,7 @@
<field name="product_id"/> <field name="product_id"/>
<field name="price_unit"/> <field name="price_unit"/>
<field name="product_qty"/> <field name="product_qty"/>
<field name="product_uom" groups="product.group_uom"/> <field name="product_uom" groups="uom.group_uom"/>
<field name="price_subtotal" widget="monetary"/> <field name="price_subtotal" widget="monetary"/>
<field name="date_planned" widget="date"/> <field name="date_planned" widget="date"/>
</tree> </tree>

View File

@@ -139,5 +139,5 @@ class RmaLineMakePurchaseOrderItem(models.TransientModel):
string='Quantity to purchase', string='Quantity to purchase',
digits=dp.get_precision('Product Unit of Measure'),) digits=dp.get_precision('Product Unit of Measure'),)
product_uom_id = fields.Many2one( product_uom_id = fields.Many2one(
comodel_name='product.uom', string='UoM') comodel_name='uom.uom', string='UoM')
free_of_charge = fields.Boolean(string='Free of Charge') free_of_charge = fields.Boolean(string='Free of Charge')

View File

@@ -30,7 +30,7 @@
<field name="name"/> <field name="name"/>
<field name="product_qty"/> <field name="product_qty"/>
<field name="product_uom_id" <field name="product_uom_id"
groups="product.group_uom"/> groups="uom.group_uom"/>
<field name="free_of_charge"/> <field name="free_of_charge"/>
</tree> </tree>
</field> </field>