mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[WIP][MIG][12.0] rma_purchase
This commit is contained in:
committed by
Chanakya Soni
parent
e7d1ef6ef9
commit
0d719f7a9a
@@ -39,6 +39,7 @@ Contributors
|
||||
* Aaron Henriquez <ahenriquez@eficent.com>
|
||||
* Lois Rilo <lois.rilo@eficent.com>
|
||||
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
|
||||
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
'name': 'RMA Purchase',
|
||||
'version': '11.0.1.0.0',
|
||||
'version': '12.0.1.0.0',
|
||||
'category': 'RMA',
|
||||
'summary': 'RMA from PO',
|
||||
'license': 'LGPL-3',
|
||||
|
||||
@@ -20,6 +20,7 @@ class RmaOrder(models.Model):
|
||||
rec.po_count = po_count
|
||||
|
||||
@api.multi
|
||||
@api.depends('rma_line_ids')
|
||||
def _compute_origin_po_count(self):
|
||||
for rma in self:
|
||||
purchases = rma.mapped(
|
||||
|
||||
@@ -78,6 +78,22 @@ class RmaOrderLine(models.Model):
|
||||
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')
|
||||
def _onchange_operation_id(self):
|
||||
res = super(RmaOrderLine, self)._onchange_operation_id()
|
||||
@@ -122,8 +138,9 @@ class RmaOrderLine(models.Model):
|
||||
'uom_id': line.product_uom.id,
|
||||
'operation_id': operation.id,
|
||||
'product_qty': line.product_qty,
|
||||
'price_unit': line.currency_id.compute(
|
||||
line.price_unit, line.currency_id, round=False),
|
||||
'price_unit': line.currency_id._convert(
|
||||
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,
|
||||
'out_route_id': operation.out_route_id.id or route,
|
||||
'receipt_policy': operation.receipt_policy,
|
||||
|
||||
@@ -1,65 +1,64 @@
|
||||
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from openerp.tests import common
|
||||
from openerp.fields import Datetime
|
||||
from odoo.tests import common
|
||||
from odoo.fields import Datetime
|
||||
|
||||
|
||||
class TestRmaPurchase(common.SingleTransactionCase):
|
||||
class TestRmaPurchase(common.TransactionCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestRmaPurchase, cls).setUpClass()
|
||||
def setUp(self):
|
||||
super(TestRmaPurchase, self).setUp()
|
||||
|
||||
cls.rma_obj = cls.env['rma.order']
|
||||
cls.rma_line_obj = cls.env['rma.order.line']
|
||||
cls.rma_op_obj = cls.env['rma.operation']
|
||||
cls.rma_add_purchase_wiz = cls.env['rma_add_purchase']
|
||||
cls.po_obj = cls.env['purchase.order']
|
||||
cls.pol_obj = cls.env['purchase.order.line']
|
||||
cls.product_obj = cls.env['product.product']
|
||||
cls.partner_obj = cls.env['res.partner']
|
||||
self.rma_obj = self.env['rma.order']
|
||||
self.rma_line_obj = self.env['rma.order.line']
|
||||
self.rma_op_obj = self.env['rma.operation']
|
||||
self.rma_add_purchase_wiz = self.env['rma_add_purchase']
|
||||
self.po_obj = self.env['purchase.order']
|
||||
self.pol_obj = self.env['purchase.order.line']
|
||||
self.product_obj = self.env['product.product']
|
||||
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
|
||||
supplier1 = cls.partner_obj.create({'name': 'Supplier 1'})
|
||||
supplier1 = self.partner_obj.create({'name': 'Supplier 1'})
|
||||
|
||||
# Create products
|
||||
cls.product_1 = cls.product_obj.create({
|
||||
self.product_1 = self.product_obj.create({
|
||||
'name': 'Test Product 1',
|
||||
'type': 'product',
|
||||
})
|
||||
cls.product_2 = cls.product_obj.create({
|
||||
self.product_2 = self.product_obj.create({
|
||||
'name': 'Test Product 2',
|
||||
'type': 'product',
|
||||
})
|
||||
|
||||
# Create PO:
|
||||
cls.po = cls.po_obj.create({
|
||||
self.po = self.po_obj.create({
|
||||
'partner_id': supplier1.id,
|
||||
})
|
||||
cls.pol_1 = cls.pol_obj.create({
|
||||
'name': cls.product_1.name,
|
||||
'order_id': cls.po.id,
|
||||
'product_id': cls.product_1.id,
|
||||
self.pol_1 = self.pol_obj.create({
|
||||
'name': self.product_1.name,
|
||||
'order_id': self.po.id,
|
||||
'product_id': self.product_1.id,
|
||||
'product_qty': 20.0,
|
||||
'product_uom': cls.product_1.uom_id.id,
|
||||
'product_uom': self.product_1.uom_id.id,
|
||||
'price_unit': 100.0,
|
||||
'date_planned': Datetime.now(),
|
||||
})
|
||||
cls.pol_2 = cls.pol_obj.create({
|
||||
'name': cls.product_2.name,
|
||||
'order_id': cls.po.id,
|
||||
'product_id': cls.product_2.id,
|
||||
self.pol_2 = self.pol_obj.create({
|
||||
'name': self.product_2.name,
|
||||
'order_id': self.po.id,
|
||||
'product_id': self.product_2.id,
|
||||
'product_qty': 18.0,
|
||||
'product_uom': cls.product_2.uom_id.id,
|
||||
'product_uom': self.product_2.uom_id.id,
|
||||
'price_unit': 150.0,
|
||||
'date_planned': Datetime.now(),
|
||||
})
|
||||
|
||||
# Create RMA group:
|
||||
cls.rma_group = cls.rma_obj.create({
|
||||
self.rma_group = self.rma_obj.create({
|
||||
'partner_id': supplier1.id,
|
||||
'type': 'supplier',
|
||||
})
|
||||
|
||||
@@ -11,18 +11,16 @@
|
||||
class="oe_stat_button"
|
||||
icon="fa-shopping-cart"
|
||||
groups="purchase.group_purchase_user">
|
||||
<field name="po_count" widget="statinfo"
|
||||
string="Purchase Orders"/>
|
||||
<field name="po_count" widget="statinfo"
|
||||
string="Purchase Orders"/>
|
||||
</button>
|
||||
</div>
|
||||
<div name='button_box' position="inside">
|
||||
<button type="object"
|
||||
name="action_view_origin_purchase_order"
|
||||
class="oe_stat_button"
|
||||
icon="fa-shopping-cart"
|
||||
groups="purchase.group_purchase_user">
|
||||
<field name="origin_po_count" widget="statinfo"
|
||||
string="Origin PO"/>
|
||||
<field name="origin_po_count" widget="statinfo"
|
||||
string="Origin PO"/>
|
||||
</button>
|
||||
</div>
|
||||
</field>
|
||||
|
||||
@@ -70,8 +70,9 @@ class RmaAddPurchase(models.TransientModel):
|
||||
'uom_id': line.product_uom.id,
|
||||
'operation_id': operation.id,
|
||||
'product_qty': line.product_qty,
|
||||
'price_unit': line.currency_id.compute(
|
||||
line.price_unit, line.currency_id, round=False),
|
||||
'price_unit': line.currency_id._convert(
|
||||
line.price_unit, line.currency_id,
|
||||
self.env.user.company_id, fields.Date.today(), round=False),
|
||||
'rma_id': self.rma_id.id,
|
||||
'in_route_id': operation.in_route_id.id or route,
|
||||
'out_route_id': operation.out_route_id.id or route,
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<field name="product_id"/>
|
||||
<field name="price_unit"/>
|
||||
<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="date_planned" widget="date"/>
|
||||
</tree>
|
||||
|
||||
@@ -139,5 +139,5 @@ class RmaLineMakePurchaseOrderItem(models.TransientModel):
|
||||
string='Quantity to purchase',
|
||||
digits=dp.get_precision('Product Unit of Measure'),)
|
||||
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')
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<field name="name"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom_id"
|
||||
groups="product.group_uom"/>
|
||||
groups="uom.group_uom"/>
|
||||
<field name="free_of_charge"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user