mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[MIG] delivery_hibou: to 14.0
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
'name': 'Delivery Hibou',
|
'name': 'Delivery Hibou',
|
||||||
'summary': 'Adds underlying pinnings for things like "RMA Return Labels"',
|
'summary': 'Adds underlying pinnings for things like "RMA Return Labels"',
|
||||||
'version': '13.0.1.0.0',
|
'version': '14.0.1.0.0',
|
||||||
'author': "Hibou Corp.",
|
'author': "Hibou Corp.",
|
||||||
'category': 'Stock',
|
'category': 'Stock',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
|||||||
@@ -12,12 +12,11 @@ class StockPicking(models.Model):
|
|||||||
], string='Require Insurance', default='auto',
|
], string='Require Insurance', default='auto',
|
||||||
help='If your carrier supports it, auto should be calculated off of the "Automatic Insurance Value" field.')
|
help='If your carrier supports it, auto should be calculated off of the "Automatic Insurance Value" field.')
|
||||||
|
|
||||||
@api.depends('move_lines.priority', 'carrier_id')
|
@api.onchange('carrier_id')
|
||||||
def _compute_priority(self):
|
def _onchange_carrier_id_for_priority(self):
|
||||||
with_carrier_priority = self.filtered(lambda p: p.carrier_id.procurement_priority)
|
for picking in self:
|
||||||
for picking in with_carrier_priority:
|
if picking.carrier_id and picking.carrier_id.procurement_priority:
|
||||||
picking.priority = picking.carrier_id.procurement_priority
|
picking.priority = picking.carrier_id.procurement_priority
|
||||||
super(StockPicking, (self-with_carrier_priority))._compute_priority()
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, values):
|
def create(self, values):
|
||||||
@@ -26,6 +25,11 @@ class StockPicking(models.Model):
|
|||||||
so = self.env['sale.order'].search([('name', '=', str(origin))], limit=1)
|
so = self.env['sale.order'].search([('name', '=', str(origin))], limit=1)
|
||||||
if so and so.shipping_account_id:
|
if so and so.shipping_account_id:
|
||||||
values['shipping_account_id'] = so.shipping_account_id.id
|
values['shipping_account_id'] = so.shipping_account_id.id
|
||||||
|
carrier_id = values.get('carrier_id')
|
||||||
|
if carrier_id:
|
||||||
|
carrier = self.env['delivery.carrier'].browse(carrier_id)
|
||||||
|
if carrier.procurement_priority:
|
||||||
|
values['priority'] = carrier.procurement_priority
|
||||||
|
|
||||||
res = super(StockPicking, self).create(values)
|
res = super(StockPicking, self).create(values)
|
||||||
return res
|
return res
|
||||||
@@ -37,12 +41,3 @@ class StockPicking(models.Model):
|
|||||||
# Assume Full Value
|
# Assume Full Value
|
||||||
cost = sum([(l.product_id.standard_price * l.product_uom_qty) for l in self.move_lines] or [0.0])
|
cost = sum([(l.product_id.standard_price * l.product_uom_qty) for l in self.move_lines] or [0.0])
|
||||||
return cost
|
return cost
|
||||||
|
|
||||||
|
|
||||||
class StockMove(models.Model):
|
|
||||||
_inherit = 'stock.move'
|
|
||||||
|
|
||||||
def _prepare_procurement_values(self):
|
|
||||||
res = super(StockMove, self)._prepare_procurement_values()
|
|
||||||
res['priority'] = self.picking_id.priority or self.priority
|
|
||||||
return res
|
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ class TestDeliveryHibou(common.TransactionCase):
|
|||||||
|
|
||||||
def test_delivery_hibou(self):
|
def test_delivery_hibou(self):
|
||||||
# Assign a new shipping account
|
# Assign a new shipping account
|
||||||
self.partner.shipping_account_id = self.shipping_account
|
self.partner.shipping_account_ids = self.shipping_account
|
||||||
|
|
||||||
# Assign values to new Carrier
|
# Assign values to new Carrier
|
||||||
test_insurance_value = 600
|
test_insurance_value = 600
|
||||||
test_procurement_priority = '2'
|
test_procurement_priority = '1'
|
||||||
self.carrier.automatic_insurance_value = test_insurance_value
|
self.carrier.automatic_insurance_value = test_insurance_value
|
||||||
self.carrier.procurement_priority = test_procurement_priority
|
self.carrier.procurement_priority = test_procurement_priority
|
||||||
|
|
||||||
@@ -135,9 +135,9 @@ class TestDeliveryHibou(common.TransactionCase):
|
|||||||
picking_in.carrier_id = self.carrier
|
picking_in.carrier_id = self.carrier
|
||||||
# This relies heavily on the 'stock' demo data.
|
# This relies heavily on the 'stock' demo data.
|
||||||
# Should only have a single move_line_ids and it should not be done at all.
|
# Should only have a single move_line_ids and it should not be done at all.
|
||||||
self.assertEqual(picking_in.move_line_ids.mapped('qty_done'), [0.0])
|
self.assertEqual(picking_in.move_line_ids.mapped('qty_done'), [0.0, 0.0, 0.0])
|
||||||
self.assertEqual(picking_in.move_line_ids.mapped('product_uom_qty'), [35.0])
|
self.assertEqual(picking_in.move_line_ids.mapped('product_uom_qty'), [35.0, 10.0, 12.0])
|
||||||
self.assertEqual(picking_in.move_line_ids.mapped('product_id.standard_price'), [55.0])
|
self.assertEqual(picking_in.move_line_ids.mapped('product_id.standard_price'), [55.0, 35.0, 1700.0])
|
||||||
|
|
||||||
self.assertEqual(picking_in.carrier_id._classify_picking(picking=picking_in), 'in')
|
self.assertEqual(picking_in.carrier_id._classify_picking(picking=picking_in), 'in')
|
||||||
self.assertEqual(picking_in.carrier_id.get_shipper_company(picking=picking_in),
|
self.assertEqual(picking_in.carrier_id.get_shipper_company(picking=picking_in),
|
||||||
|
|||||||
Reference in New Issue
Block a user