Skip to content

Commit

Permalink
[18.0][MIG] sale_blanket_order: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BertVGroenendael committed Oct 22, 2024
1 parent 3cf3bf4 commit 1151435
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 49 deletions.
2 changes: 0 additions & 2 deletions sale_blanket_order/data/ir_cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
name="nextcall"
eval="(DateTime.now() + relativedelta(hour=00, minute=1, second=0)).strftime('%Y-%m-%d %H:%M:%S')"
/>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="model_id" ref="model_sale_blanket_order" />
<field name="state">code</field>
<field name="code">model.expire_orders()</field>
Expand Down
14 changes: 2 additions & 12 deletions sale_blanket_order/models/blanket_orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ def _compute_amount_all(self):
required=True,
)
currency_id = fields.Many2one("res.currency", related="pricelist_id.currency_id")
analytic_account_id = fields.Many2one(
comodel_name="account.analytic.account",
string="Analytic Account",
copy=False,
check_company=True,
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
)
payment_term_id = fields.Many2one(
"account.payment.term",
string="Payment Terms",
Expand Down Expand Up @@ -236,8 +229,8 @@ def onchange_partner_id(self):

if self.partner_id.user_id:
values["user_id"] = self.partner_id.user_id.id

Check warning on line 231 in sale_blanket_order/models/blanket_orders.py

View check run for this annotation

Codecov / codecov/patch

sale_blanket_order/models/blanket_orders.py#L231

Added line #L231 was not covered by tests
if self.partner_id.team_id:
values["team_id"] = self.partner_id.team_id.id
if self.partner_id.user_id.sale_team_id:
values["team_id"] = self.partner_id.user_id.sale_team_id.id

Check warning on line 233 in sale_blanket_order/models/blanket_orders.py

View check run for this annotation

Codecov / codecov/patch

sale_blanket_order/models/blanket_orders.py#L233

Added line #L233 was not covered by tests
self.update(values)

def unlink(self):
Expand Down Expand Up @@ -571,9 +564,6 @@ def _get_display_price(self):
currency=self.currency_id,
)

if self.order_id.pricelist_id.discount_policy == "with_discount":
return pricelist_price

if not self.pricelist_item_id:
# No pricelist rule found => no discount from pricelist
return pricelist_price
Expand Down
3 changes: 0 additions & 3 deletions sale_blanket_order/tests/test_blanket_orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ def test_01_create_blanket_order(self):
}
)
blanket_order.sudo().onchange_partner_id()
blanket_order.pricelist_id.discount_policy = "without_discount"
blanket_order.line_ids[0].sudo().onchange_product()
blanket_order.pricelist_id.discount_policy = "with_discount"
blanket_order.line_ids[0].sudo().onchange_product()
blanket_order.line_ids[0].sudo()._get_display_price()

Expand Down
10 changes: 5 additions & 5 deletions sale_blanket_order/views/sale_blanket_order_line_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<!-- VIEWS -->

<record id="sale_blanket_order_line_tree" model="ir.ui.view">
<field name="name">sale.blanket.order.line.tree</field>
<field name="name">sale.blanket.order.line.list</field>
<field name="model">sale.blanket.order.line</field>
<field name="arch" type="xml">
<tree create="false">
<list create="false">
<field name="sequence" widget="handle" />
<field name="name" invisible="1" />
<field name="order_id" />
Expand All @@ -27,7 +27,7 @@
<field name="delivered_uom_qty" />
<field name="remaining_uom_qty" />
<field name="company_id" invisible="1" />
</tree>
</list>
</field>
</record>

Expand Down Expand Up @@ -127,7 +127,7 @@
<page name="sale_lines" string="Sale Order Lines">
<field
name="sale_lines"
mode="tree"
mode="list"
readonly="1"
domain="[('product_id', '=', product_id)]"
/>
Expand Down Expand Up @@ -164,7 +164,7 @@
<field name="name">Blanket Order Lines</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.blanket.order.line</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="sale_blanket_order_line_search" />
</record>

Expand Down
28 changes: 7 additions & 21 deletions sale_blanket_order/views/sale_blanket_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<!-- VIEWS -->

<record id="view_blanket_order_tree" model="ir.ui.view">
<field name="name">sale.blanket.order.tree</field>
<field name="name">sale.blanket.order.list</field>
<field name="model">sale.blanket.order</field>
<field name="arch" type="xml">
<tree
<list
decoration-info="state == 'draft'"
decoration-muted="state == 'expired'"
>
Expand All @@ -21,7 +21,7 @@
optional="show"
readonly="1"
/>
</tree>
</list>
</field>
</record>

Expand Down Expand Up @@ -121,7 +121,7 @@
readonly="state in ['open', 'done', 'expired']"
widget="section_and_note_one2many"
>
<tree editable="bottom">
<list editable="bottom">
<control>
<create
name="add_product_control"
Expand Down Expand Up @@ -215,7 +215,7 @@
invisible="display_type"
/>
<field name="company_id" invisible="1" />
</tree>
</list>
</field>
<group class="oe_subtotal_footer oe_right">
<field
Expand Down Expand Up @@ -268,25 +268,11 @@
groups="base.group_multi_company"
/>
</group>
<group name="invoicing" string="Invoicing">
<t groups="base.group_multi_company">
<field
name="analytic_account_id"
readonly="sale_count != 0 and state != 'draft'"
groups="analytic.group_analytic_accounting"
force_save="1"
/>
</t>
</group>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" />
<field name="activity_ids" />
<field name="message_ids" />
</div>
<chatter />
</form>
</field>
</record>
Expand Down Expand Up @@ -342,7 +328,7 @@
<field name="name">Blanket Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.blanket.order</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="view_blanket_order_search" />
<field name="domain">[]</field>
<field name="context">{}</field>
Expand Down
4 changes: 2 additions & 2 deletions sale_blanket_order/views/sale_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<field name="blanket_order_id" invisible="1" />
</field>
<xpath
expr="//field[@name='order_line']//tree/field[@name='product_id']"
expr="//field[@name='order_line']//list/field[@name='product_id']"
position="after"
>
<field
Expand All @@ -28,7 +28,7 @@
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']//tree" position="attributes">
<xpath expr="//field[@name='order_line']//list" position="attributes">
<t groups="sale_blanket_order.blanket_orders_disable_adding_lines">
<attribute name="create">blanket_order_id==False</attribute>
</t>
Expand Down
3 changes: 1 addition & 2 deletions sale_blanket_order/wizard/create_sale_orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def _prepare_so_vals(
"pricelist_id": pricelist_id,
"payment_term_id": payment_term_id,
"order_line": order_lines_by_customer[customer],
"analytic_account_id": self.blanket_order_id.analytic_account_id.id,
}

def create_sale_order(self):
Expand Down Expand Up @@ -191,7 +190,7 @@ def create_sale_order(self):
"domain": [("id", "in", res)],
"name": _("Sales Orders"),
"view_type": "form",
"view_mode": "tree,form",
"view_mode": "list,form",
"res_model": "sale.order",
"context": {"from_sale_order": True},
"type": "ir.actions.act_window",
Expand Down
4 changes: 2 additions & 2 deletions sale_blanket_order/wizard/create_sale_orders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<form string="Create Sale Order">
<group>
<field name="line_ids" nolabel="1" colspan="2">
<tree create="false" editable="bottom">
<list create="false" editable="bottom">
<field
name="blanket_line_id"
force_save="1"
Expand All @@ -20,7 +20,7 @@
<field name="remaining_uom_qty" />
<field name="product_uom" groups="uom.group_uom" />
<field name="qty" />
</tree>
</list>
</field>
</group>
<footer>
Expand Down

0 comments on commit 1151435

Please sign in to comment.