Skip to content

Commit

Permalink
Rename field for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
guewen committed Nov 6, 2019
1 parent c13ad92 commit a580542
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions stock_available_to_promise_release/models/.#stock_rule.py
8 changes: 4 additions & 4 deletions stock_available_to_promise_release/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class StockMove(models.Model):
help="Available to Promise quantity minus quantities promised "
" to older promised operations.",
)
need_rule_pull = fields.Boolean()
need_release = fields.Boolean()

@api.depends()
def _compute_ordered_available_to_promise(self):
Expand Down Expand Up @@ -53,7 +53,7 @@ def _ordered_available_to_promise(self):

def _available_to_promise_quantity_domain(self):
domain = [
("need_rule_pull", "=", True),
("need_release", "=", True),
("product_id", "=", self.product_id.id),
("date_priority", "<=", self.date_priority),
("warehouse_id", "=", self.warehouse_id.id),
Expand Down Expand Up @@ -89,7 +89,7 @@ def _prepare_move_split_vals(self, qty):
# a partially available move in _run_stock_rule().
if self.env.context.get("release_available_to_promise"):
vals.update(
{"procure_method": self.procure_method, "need_rule_pull": True}
{"procure_method": self.procure_method, "need_release": True}
)
return vals

Expand All @@ -106,7 +106,7 @@ def _run_stock_rule(self):
"Product Unit of Measure"
)
for move in self:
if not move.need_rule_pull:
if not move.need_release:
continue
if move.state not in ("confirmed", "waiting"):
continue
Expand Down
10 changes: 5 additions & 5 deletions stock_available_to_promise_release/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class StockPicking(models.Model):
# Add store on the field, as it is quite used in the searches,
# and this is an easy-win to reduce the number of SQL queries.
picking_type_code = fields.Selection(store=True)
need_rule_pull = fields.Boolean(compute="_compute_need_rule_pull")
need_release = fields.Boolean(compute="_compute_need_release")

@api.depends("move_lines.need_rule_pull")
def _compute_need_rule_pull(self):
@api.depends("move_lines.need_release")
def _compute_need_release(self):
for picking in self:
picking.need_rule_pull = any(
move.need_rule_pull for move in picking.move_lines
picking.need_release = any(
move.need_release for move in picking.move_lines
)

@api.multi
Expand Down
6 changes: 3 additions & 3 deletions stock_available_to_promise_release/models/stock_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _run_pull(
# track the moves that needs to have their pull rule
# done
if moves:
moves.write({"need_rule_pull": True})
moves.write({"need_release": True})
return True

super()._run_pull(
Expand All @@ -44,8 +44,8 @@ def _run_pull(
)
moves = values.get("move_dest_ids")
if moves:
moves.filtered(lambda r: r.need_rule_pull).write(
{"need_rule_pull": False}
moves.filtered(lambda r: r.need_release).write(
{"need_release": False}
)
return True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
(0, 0, {'view_mode': 'form', 'view_id': ref('view_move_release_form')}),
]"/>
<field name="context">{'search_default_groupby_picking_id': 1}</field>
<field name="domain">[('need_rule_pull', '=' , True)]</field>
<field name="domain">[('need_release', '=' , True)]</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new stock movement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<button name="action_confirm" position="after">
<field name="need_rule_pull" invisible="1"/>
<field name="need_release" invisible="1"/>
<button name="release_available_to_promise"
attrs="{'invisible': [('need_rule_pull', '=', False)]}"
attrs="{'invisible': [('need_release', '=', False)]}"
string="Release"
type="object"
class="oe_highlight"
Expand Down

0 comments on commit a580542

Please sign in to comment.