mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] mrp_bom_version: Show in tree buttons draft, activate, new version, and historical. Create _copy_bom, _update_bom_state_after_copy functions.
[ADD] mrp_bom_new_version_when_component_change: Create a new version of BoM when are you going to change a component.
This commit is contained in:
@@ -83,16 +83,8 @@ class MrpBom(models.Model):
|
||||
@api.multi
|
||||
def button_new_version(self):
|
||||
self.ensure_one()
|
||||
new_bom = self.copy({
|
||||
'version': self.version + 1,
|
||||
'active': True,
|
||||
'parent_bom': self.id,
|
||||
})
|
||||
self.write({
|
||||
'active': False,
|
||||
'state': 'historical',
|
||||
'historical_date': fields.Date.today(),
|
||||
})
|
||||
new_bom = self._copy_bom()
|
||||
self._update_bom_state_after_copy()
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_type': 'form, tree',
|
||||
@@ -102,6 +94,21 @@ class MrpBom(models.Model):
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
def _copy_bom(self):
|
||||
new_bom = self.copy({
|
||||
'version': self.version + 1,
|
||||
'active': True,
|
||||
'parent_bom': self.id,
|
||||
})
|
||||
return new_bom
|
||||
|
||||
def _update_bom_state_after_copy(self):
|
||||
self.write({
|
||||
'active': False,
|
||||
'state': 'historical',
|
||||
'historical_date': fields.Date.today(),
|
||||
})
|
||||
|
||||
@api.one
|
||||
def button_activate(self):
|
||||
self.write({
|
||||
|
||||
@@ -26,6 +26,29 @@
|
||||
<field name="version" />
|
||||
<field name="state" />
|
||||
<field name="historical_date"/>
|
||||
<button name="button_draft"
|
||||
type="object"
|
||||
string="Draft"
|
||||
groups="mrp_bom_version.group_mrp_bom_version"
|
||||
attrs="{'invisible':[('state','!=','active')]}"
|
||||
icon="terp-document-new" />
|
||||
<button name="button_activate"
|
||||
type="object" string="Activate"
|
||||
attrs="{'invisible':[('state','not in',(False, 'draft'))]}"
|
||||
icon="terp-camera_test"
|
||||
confirm="You will activate the BoM. If you haven't set a route yet, then you won't be able to do it after this. Are you sure you want to proceed?"/>
|
||||
<button name="button_new_version"
|
||||
type="object"
|
||||
string="New version"
|
||||
attrs="{'invisible':[('state','==','historical')]}"
|
||||
icon="gtk-execute"
|
||||
confirm="You are going to create a new version of this BoM. Are you sure?"/>
|
||||
<button name="button_historical"
|
||||
type="object"
|
||||
string="Historical"
|
||||
attrs="{'invisible':[('state','!=','active')]}"
|
||||
icon="gtk-convert"
|
||||
confirm="You are going to historize an BoM. Doing, not be able to unlock it unless you make a copy. Are you sure you want to proceed?"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user