Skip to content

Commit

Permalink
[17.0][MIG] agreement_sale: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ilo committed Sep 10, 2024
1 parent c1f431e commit 986509e
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 54 deletions.
1 change: 0 additions & 1 deletion agreement_sale/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Known issues / Roadmap

Features to evaluate before implementation

- add smart button on agreement to access implied sales
- add module agreement_account: agreement_sale'll depends on it

Bug Tracker
Expand Down
3 changes: 2 additions & 1 deletion agreement_sale/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"depends": ["sale_management", "agreement"],
"data": [
"security/ir.model.access.csv",
"views/agreement.xml",
"views/agreement_menu.xml",
"views/agreement_view.xml",
"views/sale_order.xml",
"views/res_config_settings.xml",
],
Expand Down
1 change: 1 addition & 0 deletions agreement_sale/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import agreement
from . import sale
from . import res_config_settings
33 changes: 33 additions & 0 deletions agreement_sale/models/agreement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2024 - TODAY, Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class Agreement(models.Model):
_inherit = "agreement"

sale_order_count = fields.Integer(
compute="_compute_sale_order_count", string="# Sale Orders"
)

def _compute_sale_order_count(self):
for agreement in self:
agreement.sale_order_count = self.env["sale.order"].search_count(

Check warning on line 16 in agreement_sale/models/agreement.py

View check run for this annotation

Codecov / codecov/patch

agreement_sale/models/agreement.py#L16

Added line #L16 was not covered by tests
[("agreement_id", "=", agreement.id)]
)

def action_view_sale_order(self):
for agreement in self:
sale_order_ids = self.env["sale.order"].search(

Check warning on line 22 in agreement_sale/models/agreement.py

View check run for this annotation

Codecov / codecov/patch

agreement_sale/models/agreement.py#L22

Added line #L22 was not covered by tests
[("agreement_id", "=", agreement.id)]
)
action = self.env["ir.actions.act_window"]._for_xml_id(

Check warning on line 25 in agreement_sale/models/agreement.py

View check run for this annotation

Codecov / codecov/patch

agreement_sale/models/agreement.py#L25

Added line #L25 was not covered by tests
"sale.action_quotations"
)
if len(sale_order_ids) == 1:
action["views"] = [(self.env.ref("sale.view_order_form").id, "form")]
action["res_id"] = sale_order_ids.ids[0]

Check warning on line 30 in agreement_sale/models/agreement.py

View check run for this annotation

Codecov / codecov/patch

agreement_sale/models/agreement.py#L29-L30

Added lines #L29 - L30 were not covered by tests
else:
action["domain"] = [("id", "in", sale_order_ids.ids)]
return action

Check warning on line 33 in agreement_sale/models/agreement.py

View check run for this annotation

Codecov / codecov/patch

agreement_sale/models/agreement.py#L32-L33

Added lines #L32 - L33 were not covered by tests
4 changes: 0 additions & 4 deletions agreement_sale/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ class SaleOrder(models.Model):
string="Agreement",
ondelete="restrict",
tracking=True,
readonly=True,
copy=False,
states={"draft": [("readonly", False)], "sent": [("readonly", False)]},
)

agreement_type_id = fields.Many2one(
comodel_name="agreement.type",
string="Agreement Type",
ondelete="restrict",
tracking=True,
readonly=True,
copy=True,
states={"draft": [("readonly", False)], "sent": [("readonly", False)]},
)
2 changes: 2 additions & 0 deletions agreement_sale/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Alexis de Lattre \<<[email protected]>\>
- Italo LOPES \<<[email protected]>\>
1 change: 0 additions & 1 deletion agreement_sale/readme/CONTRIBUTORS.rst

This file was deleted.

1 change: 0 additions & 1 deletion agreement_sale/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Features to evaluate before implementation

- add smart button on agreement to access implied sales
- add module agreement_account: agreement_sale'll depends on it
1 change: 0 additions & 1 deletion agreement_sale/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ <h1 class="title">Agreement Sale</h1>
<h1><a class="toc-backref" href="#toc-entry-1">Known issues / Roadmap</a></h1>
<p>Features to evaluate before implementation</p>
<ul class="simple">
<li>add smart button on agreement to access implied sales</li>
<li>add module agreement_account: agreement_sale’ll depends on it</li>
</ul>
</div>
Expand Down
File renamed without changes.
26 changes: 26 additions & 0 deletions agreement_sale/views/agreement_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<odoo>

<!-- Agreement Form View -->
<record id="agreement_sale_order_form_view" model="ir.ui.view">
<field name="name">agreement.form.fsm.order.view</field>
<field name="model">agreement</field>
<field name="inherit_id" ref="agreement.agreement_form" />
<field name="arch" type="xml">
<div class="oe_button_box" position="inside">
<button
name="action_view_sale_order"
type="object"
class="oe_stat_button"
icon="fa-shopping-cart"
>
<field
name="sale_order_count"
widget="statinfo"
string="Sale Orders"
/>
</button>
</div>
</field>
</record>

</odoo>
73 changes: 29 additions & 44 deletions agreement_sale/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,39 @@
<field name="priority" eval="11" />
<field name="inherit_id" ref="sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@data-key='sale_management']" position="inside">
<h2>Agreements</h2>
<div class="row mt16 o_settings_container">
<div
id="sales_settings_agreement_type_group"
class="col-12 col-lg-6 o_setting_box"
>
<div class="o_setting_left_pane">
<field name="group_use_agreement_type" />
<xpath expr="//app[@name='sale_management']" position="inside">
<block title="Agreements" name="agreement_settings">
<setting id="sales_settings_agreement_type_group">
<field name="group_use_agreement_type" />
<label for="group_use_agreement_type" />
<div class="text-muted">
Manage agreements by types
</div>
<div class="o_setting_right_pane">
<label for="group_use_agreement_type" />
<div class="text-muted">
Manage agreements by types
</div>
<div
class="content-group"
attrs="{'invisible': [('group_use_agreement_type','=',False)]}"
>
<div class="mt16">
<button
name="%(agreement.agreement_type_action)d"
icon="fa-arrow-right"
type="action"
string="Agreement types"
class="btn-link"
/>
</div>
<div
class="content-group"
invisible="group_use_agreement_type == False"
>
<div class="mt16">
<button
name="%(agreement.agreement_type_action)d"
icon="fa-arrow-right"
type="action"
string="Agreement types"
class="btn-link"
/>
</div>
</div>
</div>
<div
class="col-12 col-md-6 o_setting_box"
id="sales_settings_agreement_template_group"
>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="group_use_agreement_template" />
</div>
<div class="o_setting_right_pane">
<label for="group_use_agreement_template" />
<div class="text-muted">
Have a special kind of agreements which act as templates
</div>
</setting>
<setting id="sales_settings_agreement_template_group">
<setting>
<field name="group_use_agreement_template" />
<label for="group_use_agreement_template" />
<div class="text-muted">
Have a special kind of agreements which act as templates
</div>
</div>
</div>
</div>
</setting>
</setting>
</block>
</xpath>
</field>
</record>
Expand Down
3 changes: 2 additions & 1 deletion agreement_sale/views/sale_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<field name="client_order_ref" position="after">
<field name="agreement_id" />
<field name="agreement_id" readonly="state not in ('draft', 'sent')" />
</field>
<field name="partner_id" position="after">
<field
name="agreement_type_id"
readonly="state not in ('draft', 'sent')"
groups="agreement.group_use_agreement_type"
/>
</field>
Expand Down

0 comments on commit 986509e

Please sign in to comment.