Commit 28fe3c3f authored by Hbto [ Vauxoo ]'s avatar Hbto [ Vauxoo ]
Browse files

Merge pull request #774 from vauxoo-dev/8.0-mrp_routing_account_journal-hbto

8.0 mrp routing account journal hbto
parents 08601cd2 418f9a61
......@@ -3,6 +3,15 @@
from openerp import models, fields
class MrpBom(models.Model):
_inherit = 'mrp.bom'
journal_id = fields.Many2one(
'account.journal',
string='Journal',
readonly=False,
)
class MrpRouting(models.Model):
"""
For specifying the routings of Work Centers.
......
......@@ -11,5 +11,18 @@
</xpath>
</field>
</record>
<record id="mrp_bom_journal_form_view" model="ir.ui.view">
<field name="name">mrp.bom.journal.form.view</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="model">mrp.bom</field>
<field name="arch" type="xml">
<xpath expr="//label[@for='routing_id']" position="before">
<label for="journal_id" class="oe_inline" groups="account.group_account_manager"/>
<div groups="account.group_account_manager">
<field name="journal_id" class="oe_inline"/>
</div>
</xpath>
</field>
</record>
</data>
</openerp>
......@@ -37,13 +37,19 @@ class MrpProduction(models.Model):
@api.multi
def test_accounting_setting(self):
self.ensure_one()
msg = ''
if not self.routing_id:
msg_journal = _('Please set a Journal in BoM: {bom} to book '
'Production Cost Journal Entries\n')
if not self.bom_id.journal_id:
msg += msg_journal.format(bom=self.bom_id.name)
if msg:
raise UserError(msg)
return True
company_brw = self.env.user.company_id
require_workcenter_analytic = company_brw.require_workcenter_analytic
msg = ''
msg_financial = _('Add Financial Account on Worcenter: {wc}\n')
msg_hour = _('Add Hour Analytical Account on Worcenter: {wc}\n')
msg_cycle = _('Add Cycle Analytical Account on Worcenter: {wc}\n')
......@@ -135,8 +141,10 @@ class MrpProduction(models.Model):
ap_obj = self.env['account.period']
am_obj = self.env['account.move']
date = fields.Date.context_today(self)
journal_id = self.routing_id and self.routing_id.journal_id or \
self.bom_id.journal_id
vals = {
'journal_id': self.routing_id.journal_id.id,
'journal_id': journal_id.id,
'period_id': ap_obj.with_context(ctx).find(date)[:1].id,
'date': date,
'ref': self.name,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment