mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[11.0] MIG: rma_purchase
This commit is contained in:
committed by
Chanakya Soni
parent
ff51a37933
commit
d2ea82d0f0
@@ -38,6 +38,7 @@ Contributors
|
|||||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||||
* 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>
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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 . import models
|
from . import models
|
||||||
from . import wizards
|
from . import wizards
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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)
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'RMA Purchase',
|
'name': 'RMA Purchase',
|
||||||
'version': '9.0.1.0.0',
|
'version': '11.0.1.0.0',
|
||||||
'category': 'RMA',
|
'category': 'RMA',
|
||||||
'summary': 'RMA from PO',
|
'summary': 'RMA from PO',
|
||||||
'license': 'LGPL-3',
|
'license': 'LGPL-3',
|
||||||
@@ -13,6 +13,6 @@
|
|||||||
'data': ['views/rma_order_view.xml',
|
'data': ['views/rma_order_view.xml',
|
||||||
'views/rma_order_line_view.xml',
|
'views/rma_order_line_view.xml',
|
||||||
'wizards/rma_add_purchase.xml'],
|
'wizards/rma_add_purchase.xml'],
|
||||||
'installable': False,
|
'installable': True,
|
||||||
'auto_install': True,
|
'auto_install': True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# 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 . import rma_order
|
from . import rma_order
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2017 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)
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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 odoo import api, fields, models
|
|
||||||
|
from odoo import api, fields, models, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class RmaOrder(models.Model):
|
class RmaOrder(models.Model):
|
||||||
_inherit = "rma.order"
|
_inherit = "rma.order"
|
||||||
|
|
||||||
@api.depends('rma_line_ids', 'rma_line_ids.procurement_ids')
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _compute_po_count(self):
|
def _compute_po_count(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
purchases = rec.mapped('rma_line_ids.procurement_ids.purchase_id')
|
po_count = 0
|
||||||
rec.po_count = len(purchases)
|
for line in rec.rma_line_ids:
|
||||||
|
po_count += len(self.env['purchase.order'].search(
|
||||||
|
[('origin', '=', line.name)]).ids)
|
||||||
|
rec.po_count = po_count
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _compute_origin_po_count(self):
|
def _compute_origin_po_count(self):
|
||||||
@@ -30,7 +33,10 @@ class RmaOrder(models.Model):
|
|||||||
def action_view_purchase_order(self):
|
def action_view_purchase_order(self):
|
||||||
action = self.env.ref('purchase.purchase_rfq')
|
action = self.env.ref('purchase.purchase_rfq')
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
po_ids = self.mapped('rma_line_ids.procurement_ids.purchase_id').ids
|
po_ids = self.env['purchase.order'].search(
|
||||||
|
[('origin', '=', self.name)]).ids
|
||||||
|
if not po_ids:
|
||||||
|
raise ValidationError(_("No purchase order found!"))
|
||||||
result['domain'] = [('id', 'in', po_ids)]
|
result['domain'] = [('id', 'in', po_ids)]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -40,5 +46,7 @@ class RmaOrder(models.Model):
|
|||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
po_ids = self.mapped(
|
po_ids = self.mapped(
|
||||||
'rma_line_ids.purchase_order_line_id.order_id').ids
|
'rma_line_ids.purchase_order_line_id.order_id').ids
|
||||||
|
if not po_ids:
|
||||||
|
raise ValidationError(_("No purchase order found!"))
|
||||||
result['domain'] = [('id', 'in', po_ids)]
|
result['domain'] = [('id', 'in', po_ids)]
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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 odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
from odoo.addons import decimal_precision as dp
|
|
||||||
|
|
||||||
|
|
||||||
class RmaOrderLine(models.Model):
|
class RmaOrderLine(models.Model):
|
||||||
@@ -12,30 +11,19 @@ class RmaOrderLine(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def _compute_purchase_count(self):
|
def _compute_purchase_count(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
purchase_list = []
|
rec.purchase_count = len(self.env['purchase.order'].search(
|
||||||
for procurement_id in rec.procurement_ids:
|
[('origin', 'ilike', rec.name)]).ids)
|
||||||
if procurement_id.purchase_id and \
|
|
||||||
procurement_id.purchase_id.id:
|
|
||||||
purchase_list.append(procurement_id.purchase_id.id)
|
|
||||||
rec.purchase_count = len(list(set(purchase_list)))
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('procurement_ids.purchase_line_id')
|
|
||||||
def _compute_purchase_order_lines(self):
|
def _compute_purchase_order_lines(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
purchase_list = []
|
purchase_list = []
|
||||||
for procurement_id in rec.procurement_ids:
|
for purchase in self.env['purchase.order'].search(
|
||||||
if procurement_id.purchase_line_id and \
|
[('origin', 'ilike', rec.name)]):
|
||||||
procurement_id.purchase_line_id.id:
|
for line in purchase.order_line:
|
||||||
purchase_list.append(procurement_id.purchase_line_id.id)
|
purchase_list.append(line.id)
|
||||||
rec.purchase_order_line_ids = [(6, 0, purchase_list)]
|
rec.purchase_order_line_ids = [(6, 0, purchase_list)]
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends('procurement_ids.purchase_line_id')
|
|
||||||
def _compute_qty_purchased(self):
|
|
||||||
for rec in self:
|
|
||||||
rec.qty_purchased = rec._get_rma_purchased_qty()
|
|
||||||
|
|
||||||
purchase_count = fields.Integer(
|
purchase_count = fields.Integer(
|
||||||
compute='_compute_purchase_count', string='# of Purchases',
|
compute='_compute_purchase_count', string='# of Purchases',
|
||||||
)
|
)
|
||||||
@@ -55,11 +43,6 @@ class RmaOrderLine(models.Model):
|
|||||||
column1='rma_order_line_id', column2='purchase_order_line_id',
|
column1='rma_order_line_id', column2='purchase_order_line_id',
|
||||||
string='Purchase Order Lines', compute='_compute_purchase_order_lines',
|
string='Purchase Order Lines', compute='_compute_purchase_order_lines',
|
||||||
)
|
)
|
||||||
qty_purchased = fields.Float(
|
|
||||||
string='Qty Purchased', copy=False,
|
|
||||||
digits=dp.get_precision('Product Unit of Measure'),
|
|
||||||
readonly=True, compute='_compute_qty_purchased', store=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _prepare_rma_line_from_po_line(self, line):
|
def _prepare_rma_line_from_po_line(self, line):
|
||||||
@@ -139,25 +122,3 @@ class RmaOrderLine(models.Model):
|
|||||||
if not exception == 'purchase_order_line_id':
|
if not exception == 'purchase_order_line_id':
|
||||||
self.purchase_order_line_id = False
|
self.purchase_order_line_id = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_purchase_order(self):
|
|
||||||
action = self.env.ref('purchase.purchase_rfq')
|
|
||||||
result = action.read()[0]
|
|
||||||
order_ids = []
|
|
||||||
for procurement_id in self.procurement_ids:
|
|
||||||
order_ids.append(procurement_id.purchase_id.id)
|
|
||||||
result['domain'] = [('id', 'in', order_ids)]
|
|
||||||
return result
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _get_rma_purchased_qty(self):
|
|
||||||
self.ensure_one()
|
|
||||||
qty = 0.0
|
|
||||||
for procurement_id in self.procurement_ids:
|
|
||||||
purchase_line = procurement_id.purchase_line_id
|
|
||||||
if self.type == 'supplier':
|
|
||||||
qty += purchase_line.product_qty
|
|
||||||
else:
|
|
||||||
qty = 0.0
|
|
||||||
return qty
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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 . import test_rma
|
from . import test_rma
|
||||||
from . import test_supplier_rma
|
from . import test_supplier_rma
|
||||||
from . import test_rma_dropship
|
from . import test_rma_dropship
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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)
|
||||||
|
|
||||||
@@ -267,13 +266,10 @@ class TestRma(common.TransactionCase):
|
|||||||
self.rma_customer_id._compute_po_count()
|
self.rma_customer_id._compute_po_count()
|
||||||
self.rma_customer_id._compute_origin_po_count()
|
self.rma_customer_id._compute_origin_po_count()
|
||||||
|
|
||||||
self.rma_customer_id.action_view_purchase_order()
|
|
||||||
self.rma_customer_id.action_view_origin_purchase_order()
|
self.rma_customer_id.action_view_origin_purchase_order()
|
||||||
|
|
||||||
self.rma_customer_id.rma_line_ids[0]._compute_purchase_count()
|
self.rma_customer_id.rma_line_ids[0]._compute_purchase_count()
|
||||||
self.rma_customer_id.rma_line_ids[0]._compute_purchase_order_lines()
|
self.rma_customer_id.rma_line_ids[0]._compute_purchase_order_lines()
|
||||||
self.rma_customer_id.rma_line_ids[0].action_view_purchase_order()
|
|
||||||
self.rma_customer_id.rma_line_ids[0]._get_rma_purchased_qty()
|
|
||||||
|
|
||||||
def test_rma_add_purchase_wizard(self):
|
def test_rma_add_purchase_wizard(self):
|
||||||
wizard = self.env['rma_add_purchase'].with_context({
|
wizard = self.env['rma_add_purchase'].with_context({
|
||||||
@@ -320,13 +316,11 @@ class TestRma(common.TransactionCase):
|
|||||||
'picking_type': 'incoming',
|
'picking_type': 'incoming',
|
||||||
'active_id': 1
|
'active_id': 1
|
||||||
}).create({})
|
}).create({})
|
||||||
procurements = wizard._create_picking()
|
wizard._create_picking()
|
||||||
group_ids = set([proc.group_id.id for proc in procurements if
|
res = self.rma_customer_id.rma_line_ids.action_view_in_shipments()
|
||||||
proc.group_id])
|
self.assertTrue('res_id' in res,
|
||||||
domain = [('group_id', 'in', list(group_ids))]
|
|
||||||
picking = self.stockpicking.search(domain)
|
|
||||||
self.assertEquals(len(picking), 1,
|
|
||||||
"Incorrect number of pickings created")
|
"Incorrect number of pickings created")
|
||||||
|
picking = self.env['stock.picking'].browse(res['res_id'])
|
||||||
moves = picking.move_lines
|
moves = picking.move_lines
|
||||||
self.assertEquals(len(moves), 3,
|
self.assertEquals(len(moves), 3,
|
||||||
"Incorrect number of moves created")
|
"Incorrect number of moves created")
|
||||||
@@ -356,8 +350,11 @@ class TestRma(common.TransactionCase):
|
|||||||
"Wrong qty to receive")
|
"Wrong qty to receive")
|
||||||
self.assertEquals(line.qty_incoming, 2,
|
self.assertEquals(line.qty_incoming, 2,
|
||||||
"Wrong qty incoming")
|
"Wrong qty incoming")
|
||||||
|
picking.action_confirm()
|
||||||
picking.action_assign()
|
picking.action_assign()
|
||||||
picking.do_transfer()
|
for line in picking.move_line_ids:
|
||||||
|
line.qty_done = line.product_uom_qty
|
||||||
|
picking.action_done()
|
||||||
for line in self.rma_customer_id.rma_line_ids:
|
for line in self.rma_customer_id.rma_line_ids:
|
||||||
self.assertEquals(line.qty_to_receive, 0,
|
self.assertEquals(line.qty_to_receive, 0,
|
||||||
"Wrong qty to_receive")
|
"Wrong qty to_receive")
|
||||||
@@ -389,17 +386,12 @@ class TestRma(common.TransactionCase):
|
|||||||
'active_model': 'rma.order.line',
|
'active_model': 'rma.order.line',
|
||||||
'picking_type': 'outgoing',
|
'picking_type': 'outgoing',
|
||||||
}).create({})
|
}).create({})
|
||||||
procurements = wizard._create_picking()
|
wizard._create_picking()
|
||||||
group_ids = set([proc.group_id.id for proc in procurements if
|
res = self.rma_customer_id.rma_line_ids.action_view_out_shipments()
|
||||||
proc.group_id])
|
self.assertTrue('res_id' in res,
|
||||||
domain = [('group_id', 'in', list(group_ids))]
|
|
||||||
pickings = self.stockpicking.search(domain)
|
|
||||||
procurements[0].purchase_id = self._create_purchase_order().id
|
|
||||||
wizard._get_action(pickings, procurements)
|
|
||||||
self.assertEquals(len(pickings), 2,
|
|
||||||
"Incorrect number of pickings created")
|
"Incorrect number of pickings created")
|
||||||
picking_out = pickings[1]
|
picking = self.env['stock.picking'].browse(res['res_id'])
|
||||||
moves = picking_out.move_lines
|
moves = picking.move_lines
|
||||||
self.assertEquals(len(moves), 3,
|
self.assertEquals(len(moves), 3,
|
||||||
"Incorrect number of moves created")
|
"Incorrect number of moves created")
|
||||||
for line in self.rma_customer_id.rma_line_ids:
|
for line in self.rma_customer_id.rma_line_ids:
|
||||||
@@ -430,8 +422,11 @@ class TestRma(common.TransactionCase):
|
|||||||
"Wrong qty to deliver")
|
"Wrong qty to deliver")
|
||||||
self.assertEquals(line.qty_outgoing, 2,
|
self.assertEquals(line.qty_outgoing, 2,
|
||||||
"Wrong qty outgoing")
|
"Wrong qty outgoing")
|
||||||
picking_out.action_assign()
|
picking.action_confirm()
|
||||||
picking_out.do_transfer()
|
picking.action_assign()
|
||||||
|
for line in picking.move_line_ids:
|
||||||
|
line.qty_done = line.product_uom_qty
|
||||||
|
picking.action_done()
|
||||||
for line in self.rma_customer_id.rma_line_ids:
|
for line in self.rma_customer_id.rma_line_ids:
|
||||||
self.assertEquals(line.qty_to_receive, 0,
|
self.assertEquals(line.qty_to_receive, 0,
|
||||||
"Wrong qty to receive")
|
"Wrong qty to receive")
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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)
|
||||||
|
|
||||||
@@ -45,13 +44,11 @@ class TestRmaDropship(test_rma.TestRma):
|
|||||||
'active_model': 'rma.order.line',
|
'active_model': 'rma.order.line',
|
||||||
'picking_type': 'incoming',
|
'picking_type': 'incoming',
|
||||||
}).create({})
|
}).create({})
|
||||||
procurements = wizard._create_picking()
|
wizard._create_picking()
|
||||||
group_ids = set([proc.group_id.id for proc in procurements if
|
res = supplier_rma.rma_line_ids.action_view_in_shipments()
|
||||||
proc.group_id])
|
self.assertTrue('res_id' in res,
|
||||||
domain = [('group_id', 'in', list(group_ids))]
|
|
||||||
picking = self.stockpicking.search(domain)
|
|
||||||
self.assertEquals(len(picking), 1,
|
|
||||||
"Incorrect number of pickings created")
|
"Incorrect number of pickings created")
|
||||||
|
picking = self.env['stock.picking'].browse(res['res_id'])
|
||||||
moves = picking.move_lines
|
moves = picking.move_lines
|
||||||
self.assertEquals(len(moves), 3,
|
self.assertEquals(len(moves), 3,
|
||||||
"Incorrect number of moves created")
|
"Incorrect number of moves created")
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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)
|
||||||
|
|
||||||
@@ -22,13 +21,11 @@ class TestSupplierRma(test_rma.TestRma):
|
|||||||
'picking_type': 'outgoing',
|
'picking_type': 'outgoing',
|
||||||
'active_id': 1
|
'active_id': 1
|
||||||
}).create({})
|
}).create({})
|
||||||
procurements = wizard._create_picking()
|
wizard._create_picking()
|
||||||
group_ids = set([proc.group_id.id for proc in procurements if
|
res = self.rma_supplier_id.rma_line_ids.action_view_out_shipments()
|
||||||
proc.group_id])
|
self.assertTrue('res_id' in res,
|
||||||
domain = [('group_id', 'in', list(group_ids))]
|
|
||||||
picking = self.stockpicking.search(domain)
|
|
||||||
self.assertEquals(len(picking), 1,
|
|
||||||
"Incorrect number of pickings created")
|
"Incorrect number of pickings created")
|
||||||
|
picking = self.env['stock.picking'].browse(res['res_id'])
|
||||||
moves = picking.move_lines
|
moves = picking.move_lines
|
||||||
self.assertEquals(len(moves), 3,
|
self.assertEquals(len(moves), 3,
|
||||||
"Incorrect number of moves created")
|
"Incorrect number of moves created")
|
||||||
@@ -64,24 +61,26 @@ class TestSupplierRma(test_rma.TestRma):
|
|||||||
"Wrong qty outgoing")
|
"Wrong qty outgoing")
|
||||||
|
|
||||||
picking.action_assign()
|
picking.action_assign()
|
||||||
picking.do_new_transfer()
|
for line in picking.move_lines:
|
||||||
|
line.quantity_done = line.product_uom_qty
|
||||||
|
picking.button_validate()
|
||||||
for line in self.rma_supplier_id.rma_line_ids:
|
for line in self.rma_supplier_id.rma_line_ids:
|
||||||
self.assertEquals(line.qty_incoming, 0,
|
self.assertEquals(line.qty_incoming, 0,
|
||||||
"Wrong qty incoming")
|
"Wrong qty incoming")
|
||||||
self.assertEquals(line.qty_received, 0,
|
self.assertEquals(line.qty_received, 0,
|
||||||
"Wrong qty received")
|
"Wrong qty received")
|
||||||
if line.product_id == self.product_1:
|
if line.product_id == self.product_1:
|
||||||
self.assertEquals(line.qty_delivered, 0,
|
self.assertEquals(line.qty_delivered, 3,
|
||||||
"Wrong qty delivered")
|
"Wrong qty delivered")
|
||||||
self.assertEquals(line.qty_to_receive, 3,
|
self.assertEquals(line.qty_to_receive, 3,
|
||||||
"Wrong qty to receive")
|
"Wrong qty to receive")
|
||||||
if line.product_id == self.product_2:
|
if line.product_id == self.product_2:
|
||||||
self.assertEquals(line.qty_outgoing, 5,
|
self.assertEquals(line.qty_outgoing, 0,
|
||||||
"Wrong qty outgoing")
|
"Wrong qty outgoing")
|
||||||
self.assertEquals(line.qty_to_receive, 5,
|
self.assertEquals(line.qty_to_receive, 5,
|
||||||
"Wrong qty to receive")
|
"Wrong qty to receive")
|
||||||
if line.product_id == self.product_3:
|
if line.product_id == self.product_3:
|
||||||
self.assertEquals(line.qty_outgoing, 2,
|
self.assertEquals(line.qty_outgoing, 0,
|
||||||
"Wrong qty delivered")
|
"Wrong qty delivered")
|
||||||
self.assertEquals(line.qty_to_receive, 2,
|
self.assertEquals(line.qty_to_receive, 2,
|
||||||
"Wrong qty to receive")
|
"Wrong qty to receive")
|
||||||
@@ -91,65 +90,48 @@ class TestSupplierRma(test_rma.TestRma):
|
|||||||
'active_model': 'rma.order.line',
|
'active_model': 'rma.order.line',
|
||||||
'picking_type': 'incoming',
|
'picking_type': 'incoming',
|
||||||
}).create({})
|
}).create({})
|
||||||
procurements = wizard._create_picking()
|
wizard._create_picking()
|
||||||
group_ids = set([proc.group_id.id for proc in procurements if
|
res = self.rma_supplier_id.rma_line_ids.action_view_in_shipments()
|
||||||
proc.group_id])
|
self.assertTrue('res_id' in res,
|
||||||
domain = [('group_id', 'in', list(group_ids))]
|
|
||||||
pickings = self.stockpicking.search(domain)
|
|
||||||
self.assertEquals(len(pickings), 2,
|
|
||||||
"Incorrect number of pickings created")
|
"Incorrect number of pickings created")
|
||||||
picking_out = pickings[1]
|
picking = self.env['stock.picking'].browse(res['res_id'])
|
||||||
moves = picking_out.move_lines
|
moves = picking.move_lines
|
||||||
self.assertEquals(len(moves), 3,
|
self.assertEquals(len(moves), 3,
|
||||||
"Incorrect number of moves created")
|
"Incorrect number of moves created")
|
||||||
for line in self.rma_supplier_id.rma_line_ids:
|
for line in self.rma_supplier_id.rma_line_ids:
|
||||||
self.assertEquals(line.qty_incoming, 0,
|
|
||||||
"Wrong qty incoming")
|
|
||||||
self.assertEquals(line.qty_received, 0,
|
self.assertEquals(line.qty_received, 0,
|
||||||
"Wrong qty received")
|
"Wrong qty received")
|
||||||
if line.product_id == self.product_1:
|
if line.product_id == self.product_1:
|
||||||
self.assertEquals(line.qty_to_receive, 3,
|
self.assertEquals(line.qty_to_receive, 3,
|
||||||
"Wrong qty to receive")
|
"Wrong qty to receive")
|
||||||
self.assertEquals(line.qty_incoming, 0,
|
self.assertEquals(line.qty_incoming, 3,
|
||||||
"Wrong qty incoming")
|
"Wrong qty incoming")
|
||||||
self.assertEquals(line.qty_delivered, 0,
|
|
||||||
"Wrong qty delivered")
|
|
||||||
if line.product_id == self.product_2:
|
if line.product_id == self.product_2:
|
||||||
self.assertEquals(line.qty_to_receive, 5,
|
self.assertEquals(line.qty_to_receive, 5,
|
||||||
"Wrong qty to receive")
|
"Wrong qty to receive")
|
||||||
self.assertEquals(line.qty_to_deliver, 5,
|
self.assertEquals(line.qty_incoming, 5,
|
||||||
"Wrong qty to deliver")
|
"Wrong qty incoming")
|
||||||
if line.product_id == self.product_3:
|
if line.product_id == self.product_3:
|
||||||
self.assertEquals(line.qty_to_receive, 2,
|
self.assertEquals(line.qty_to_receive, 2,
|
||||||
"Wrong qty to receive")
|
"Wrong qty to receive")
|
||||||
self.assertEquals(line.qty_to_deliver, 2,
|
self.assertEquals(line.qty_incoming, 2,
|
||||||
"Wrong qty to deliver")
|
"Wrong qty incoming")
|
||||||
picking_out.action_assign()
|
picking.action_assign()
|
||||||
picking_out.do_new_transfer()
|
for line in picking.move_line_ids:
|
||||||
|
line.qty_done = line.product_uom_qty
|
||||||
|
picking.action_done()
|
||||||
for line in self.rma_supplier_id.rma_line_ids[0]:
|
for line in self.rma_supplier_id.rma_line_ids[0]:
|
||||||
self.assertEquals(line.qty_to_receive, 3,
|
|
||||||
"Wrong qty to receive")
|
|
||||||
self.assertEquals(line.qty_incoming, 0,
|
self.assertEquals(line.qty_incoming, 0,
|
||||||
"Wrong qty incoming")
|
"Wrong qty incoming")
|
||||||
self.assertEquals(line.qty_delivered, 0,
|
|
||||||
"Wrong qty deliver")
|
|
||||||
self.assertEquals(line.qty_outgoing, 6,
|
|
||||||
"Wrong qty outgoing")
|
|
||||||
if line.product_id == self.product_1:
|
if line.product_id == self.product_1:
|
||||||
self.assertEquals(line.qty_received, 0,
|
self.assertEquals(line.qty_received, 3,
|
||||||
"Wrong qty received")
|
"Wrong qty received")
|
||||||
self.assertEquals(line.qty_delivered, 0,
|
|
||||||
"Wrong qty delivered")
|
|
||||||
if line.product_id == self.product_2:
|
if line.product_id == self.product_2:
|
||||||
self.assertEquals(line.qty_received, 0,
|
self.assertEquals(line.qty_received, 5,
|
||||||
"Wrong qty received")
|
"Wrong qty received")
|
||||||
self.assertEquals(line.qty_delivered, 5,
|
|
||||||
"Wrong qty delivered")
|
|
||||||
if line.product_id == self.product_3:
|
if line.product_id == self.product_3:
|
||||||
self.assertEquals(line.qty_received, 2,
|
self.assertEquals(line.qty_received, 2,
|
||||||
"Wrong qty received")
|
"Wrong qty received")
|
||||||
self.assertEquals(line.qty_delivered, 2,
|
|
||||||
"Wrong qty delivered")
|
|
||||||
for line in self.rma_supplier_id.rma_line_ids:
|
for line in self.rma_supplier_id.rma_line_ids:
|
||||||
line.action_rma_done()
|
line.action_rma_done()
|
||||||
self.assertEquals(line.state, 'done',
|
self.assertEquals(line.state, 'done',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="view_rma_line_form" model="ir.ui.view">
|
<record id="view_rma_line_form" model="ir.ui.view">
|
||||||
@@ -6,15 +6,6 @@
|
|||||||
<field name="model">rma.order.line</field>
|
<field name="model">rma.order.line</field>
|
||||||
<field name="inherit_id" ref="rma.view_rma_line_supplier_form"/>
|
<field name="inherit_id" ref="rma.view_rma_line_supplier_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<div name='button_box' position="inside">
|
|
||||||
<button type="object" name="action_view_purchase_order"
|
|
||||||
class="oe_stat_button"
|
|
||||||
icon="fa-shopping-cart"
|
|
||||||
groups="purchase.group_purchase_user">
|
|
||||||
<field name="purchase_count" widget="statinfo"
|
|
||||||
string="Purchase Orders"/>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<group name="main_info" position="inside">
|
<group name="main_info" position="inside">
|
||||||
<field name="purchase_order_line_id"
|
<field name="purchase_order_line_id"
|
||||||
options="{'no_create': True}"
|
options="{'no_create': True}"
|
||||||
@@ -22,11 +13,6 @@
|
|||||||
('order_id.partner_id', '=', partner_id),
|
('order_id.partner_id', '=', partner_id),
|
||||||
('order_id.partner_id', 'child_of', partner_id)]"/>
|
('order_id.partner_id', 'child_of', partner_id)]"/>
|
||||||
</group>
|
</group>
|
||||||
<group name="quantities" position="inside">
|
|
||||||
<group>
|
|
||||||
<field name="qty_purchased"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
<field name="origin" position="after">
|
<field name="origin" position="after">
|
||||||
<field name="purchase_id"
|
<field name="purchase_id"
|
||||||
attrs="{'invisible': [('purchase_order_line_id', '=', False)]}"/>
|
attrs="{'invisible': [('purchase_order_line_id', '=', False)]}"/>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="view_rma_supplier_form" model="ir.ui.view">
|
<record id="view_rma_supplier_form" model="ir.ui.view">
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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)
|
||||||
|
|
||||||
@@ -91,8 +90,6 @@ class RmaAddPurchase(models.TransientModel):
|
|||||||
def _get_rma_data(self):
|
def _get_rma_data(self):
|
||||||
data = {
|
data = {
|
||||||
'date_rma': fields.Datetime.now(),
|
'date_rma': fields.Datetime.now(),
|
||||||
'delivery_address_id': self.purchase_id.partner_id.id,
|
|
||||||
'invoice_address_id': self.purchase_id.partner_id.id
|
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="view_rma_add_purchase" model="ir.ui.view">
|
<record id="view_rma_add_purchase" model="ir.ui.view">
|
||||||
@@ -71,6 +71,4 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 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 odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user