Skip to content

Commit

Permalink
[11.0][FIX] mrp_multi_level:
Browse files Browse the repository at this point in the history
 * calendar defined only in warehouse.
 * remove raw query.
  • Loading branch information
LoisRForgeFlow authored and JordiBForgeFlow committed Aug 9, 2018
1 parent 1a2ad16 commit 1e204b9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion mrp_multi_level/data/mrp_area_data.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">

<record id="mrp_area_stock_wh0" model="mrp.area">
<field name="name">WH/Stock</field>
<field name="warehouse_id" ref="stock.warehouse0"/>
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="calendar_id" ref="resource.resource_calendar_std"/>
</record>

</odoo>
7 changes: 5 additions & 2 deletions mrp_multi_level/models/mrp_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ class MrpArea(models.Model):
required=True,
)
active = fields.Boolean(default=True)
calendar_id = fields.Many2one('resource.calendar',
'Working Hours')
calendar_id = fields.Many2one(
comodel_name='resource.calendar',
string='Working Hours',
related='warehouse_id.calendar_id',
)
3 changes: 3 additions & 0 deletions mrp_multi_level/readme/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

* [FIX] User and system locales doesn't break MRP calculation.
(`#290 <https://github.com/OCA/manufacture/pull/290>`_)
* [FIX] Working Hours are now defined only at Warehouse level and displayed
as a related on MRP Areas.
(`#290 <https://github.com/OCA/manufacture/pull/290>`__)

11.0.1.0.0 (2018-07-09)
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
7 changes: 4 additions & 3 deletions mrp_multi_level/tests/test_mrp_multi_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def setUpClass(cls):
cls.customer_location = cls.env.ref(
'stock.stock_location_customers')
cls.calendar = cls.env.ref('resource.resource_calendar_std')
# Add calendar to WH:
cls.wh.calendar_id = cls.calendar

# Partner:
vendor1 = cls.partner_obj.create({'name': 'Vendor 1'})
Expand Down Expand Up @@ -367,9 +369,8 @@ def test_07_procure_mo(self):
('product_id', '=', self.fp_1.id)])
self.assertTrue(mos)
self.assertEqual(mos.product_qty, 100.0)
datetime_5 = fields.Datetime.to_string(
self.calendar.plan_days(5 + 1, datetime.today()).date())
self.assertEqual(mos.date_planned_start, datetime_5)
mo_date_start = mos.date_planned_start.split(' ')[0]
self.assertEqual(mo_date_start, self.date_5)

# TODO: test procure wizard: pos, multiple...
# TODO: test multiple destination IDS:...
6 changes: 1 addition & 5 deletions mrp_multi_level/wizards/mrp_multi_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,7 @@ def create_move(self, mrp_product_id, mrp_date, mrp_qty, name):
mrp_date_demand_2,
bom, name)
mrpmove_id2 = self.env['mrp.move'].create(move_data)
sql_stat = "INSERT INTO mrp_move_rel (" \
"move_up_id, " \
"move_down_id) values (%d, %d)" % \
(mrpmove_id, mrpmove_id2, )
self.env.cr.execute(sql_stat)
mrpmove_id.mrp_move_down_ids = [(4, mrpmove_id2.id)]
values['qty_ordered'] = qty_ordered
log_msg = '%s' % qty_ordered
logger.info(log_msg)
Expand Down

0 comments on commit 1e204b9

Please sign in to comment.