[IMP] mrp_bom_line_sequence: black, isort

This commit is contained in:
ps-tubtim
2020-03-12 11:11:15 +07:00
parent 3e42a041f0
commit 6e218655b6
3 changed files with 28 additions and 27 deletions

View File

@@ -2,15 +2,14 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
'name': 'BOM lines with sequence number',
'summary': 'Manages the order of BOM lines by displaying its sequence',
'version': '12.0.1.0.0',
'category': 'Manufacturing Management',
'author': "Eficent, "
"Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/manufacture',
'license': "AGPL-3",
'depends': ['mrp'],
'data': ['views/stock_view.xml'],
'installable': True,
"name": "BOM lines with sequence number",
"summary": "Manages the order of BOM lines by displaying its sequence",
"version": "13.0.1.0.0",
"category": "Manufacturing Management",
"author": "Eficent, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture",
"license": "AGPL-3",
"depends": ["mrp"],
"data": ["views/stock_view.xml"],
"installable": True,
}

View File

@@ -5,30 +5,34 @@ from odoo import api, fields, models
class MrpBomLine(models.Model):
_inherit = 'mrp.bom.line'
_inherit = "mrp.bom.line"
# re-defines the field to change the default
sequence = fields.Integer(default=9999, string='original sequence')
sequence = fields.Integer(default=9999, string="original sequence")
# displays sequence on the stock moves
sequence2 = fields.Integer(help="Shows the sequence in the BOM line.",
string='Sequence',
related='sequence', readonly=False, store=True)
sequence2 = fields.Integer(
help="Shows the sequence in the BOM line.",
string="Sequence",
related="sequence",
readonly=False,
store=True,
)
@api.model
def create(self, values):
move = super(MrpBomLine, self).create(values)
# We do not reset the sequence if we are copying a complete bom
if not self.env.context.get('keep_line_sequence', False):
if not self.env.context.get("keep_line_sequence", False):
move.bom_id._reset_sequence()
return move
class MrpBom(models.Model):
_inherit = 'mrp.bom'
_inherit = "mrp.bom"
@api.multi
@api.depends('bom_line_ids')
@api.depends("bom_line_ids")
def _compute_max_line_sequence(self):
"""Allow to know the highest sequence entered in move lines.
Then we add 1 to this value for the next sequence, this value is
@@ -37,12 +41,11 @@ class MrpBom(models.Model):
incremented by 1. (max_sequence + 1)
"""
for bom in self:
bom.max_line_sequence = (
max(bom.mapped('bom_line_ids.sequence') or [0]) + 1
)
bom.max_line_sequence = max(bom.mapped("bom_line_ids.sequence") or [0]) + 1
max_line_sequence = fields.Integer(string='Max sequence in lines',
compute='_compute_max_line_sequence')
max_line_sequence = fields.Integer(
string="Max sequence in lines", compute="_compute_max_line_sequence"
)
@api.multi
def _reset_sequence(self):
@@ -54,5 +57,4 @@ class MrpBom(models.Model):
@api.multi
def copy(self, default=None):
return super(MrpBom,
self.with_context(keep_line_sequence=True)).copy(default)
return super(MrpBom, self.with_context(keep_line_sequence=True)).copy(default)

View File

@@ -1 +1 @@
* Eficent Business and IT Consulting Services S.L. <contact@eficent.com>
* Eficent Business and IT Consulting Services S.L. <contact@eficent.com>