Skip to content

Commit

Permalink
[MIG] account_billing: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkhao committed Jan 15, 2025
1 parent 18442cf commit dc9b777
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
1 change: 1 addition & 0 deletions account_billing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Contributors
- Saran Lim. <saranl@ecosoft.co.th>
- Rattapong Chokmasermkul <rattapongc@ecosoft.co.th>
- Komsan Somwong <komsan.s@ecosoft.co.th>
- Kevin Khao <kkh@360erp.com>

Maintainers
-----------
Expand Down
20 changes: 10 additions & 10 deletions account_billing/models/account_billing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019 Ecosoft Co., Ltd (https://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError, ValidationError


Expand Down Expand Up @@ -133,7 +133,7 @@ def name_get(self):
def validate_billing(self):
for rec in self:
if not rec.billing_line_ids:
raise UserError(_("You need to add a line before validate."))
raise UserError(self.env._("You need to add a line before validate."))
date_type = dict(self._fields["threshold_date_type"].selection).get(
self.threshold_date_type
)
Expand All @@ -147,7 +147,7 @@ def validate_billing(self):
for b in rec.billing_line_ids
):
raise ValidationError(
_("Threshold Date cannot be later than the %s in lines")
self.env._("Threshold Date cannot be later than the %s in lines")
% (date_type)
)
# keep the number in case of a billing reset to draft
Expand All @@ -163,13 +163,13 @@ def validate_billing(self):
.next_by_code(sequence_code)
)
rec.write({"state": "billed"})
rec.message_post(body=_("Billing is billed."))
rec.message_post(body=self.env._("Billing is billed."))
return True

def action_cancel_draft(self):
for rec in self:
rec.write({"state": "draft"})
rec.message_post(body=_("Billing is reset to draft"))
rec.message_post(body=self.env._("Billing is reset to draft"))
return True

def action_cancel(self):
Expand All @@ -178,9 +178,9 @@ def action_cancel(self):
lambda m: m.payment_state == "paid"
)
if invoice_paid:
raise ValidationError(_("Invoice paid already."))
raise ValidationError(self.env._("Invoice paid already."))
rec.write({"state": "cancel"})
self.message_post(body=_("Billing %s is cancelled") % rec.name)
self.message_post(body=self.env._("Billing %s is cancelled") % rec.name)
return True

def action_register_payment(self):
Expand All @@ -189,12 +189,12 @@ def action_register_payment(self):
def invoice_relate_billing_tree_view(self):
name = self.bill_type == "out_invoice" and "Invoices" or "Bills"
return {
"name": _("%s") % (name),
"view_mode": "tree,form",
"name": self.env._("%s") % (name),
"view_mode": "list,form",
"res_model": "account.move",
"view_id": False,
"views": [
(self.env.ref("account.view_move_tree").id, "tree"),
(self.env.ref("account.view_move_tree").id, "list"),
(self.env.ref("account.view_move_form").id, "form"),
],
"type": "ir.actions.act_window",
Expand Down
12 changes: 6 additions & 6 deletions account_billing/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019 Ecosoft Co., Ltd (https://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import Command, _, fields, models
from odoo import Command, fields, models
from odoo.exceptions import UserError


Expand Down Expand Up @@ -46,14 +46,14 @@ def action_create_billing(self):
partner = self.mapped("partner_id")
currency_ids = self.mapped("currency_id")
if len(partner) > 1:
raise UserError(_("Please select invoices with same partner"))
raise UserError(self.env._("Please select invoices with same partner"))

if len(currency_ids) > 1:
raise UserError(_("Please select invoices with same currency"))
raise UserError(self.env._("Please select invoices with same currency"))

if any(move.state != "posted" or move.payment_state == "paid" for move in self):
raise UserError(
_(
self.env._(
"Billing cannot be processed because "
"some invoices are not in the 'Posted' or 'Paid' state already."
)
Expand All @@ -62,7 +62,7 @@ def action_create_billing(self):
billing = self._create_billing(partner)

action = {
"name": _("Billing"),
"name": self.env._("Billing"),
"type": "ir.actions.act_window",
"res_model": "account.billing",
"context": {"create": False},
Expand All @@ -77,7 +77,7 @@ def action_create_billing(self):
else:
action.update(

Check warning on line 78 in account_billing/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_billing/models/account_move.py#L78

Added line #L78 was not covered by tests
{
"view_mode": "tree,form",
"view_mode": "list,form",
"domain": [("id", "in", billing.ids)],
}
)
Expand Down
1 change: 1 addition & 0 deletions account_billing/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
- Saran Lim. \<<saranl@ecosoft.co.th>\>
- Rattapong Chokmasermkul \<<rattapongc@ecosoft.co.th>\>
- Komsan Somwong \<<komsan.s@ecosoft.co.th>\>
- Kevin Khao \<<kkh@360erp.com>\>
1 change: 1 addition & 0 deletions account_billing/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Saran Lim. &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
<li>Rattapong Chokmasermkul &lt;<a class="reference external" href="mailto:rattapongc&#64;ecosoft.co.th">rattapongc&#64;ecosoft.co.th</a>&gt;</li>
<li>Komsan Somwong &lt;<a class="reference external" href="mailto:komsan.s&#64;ecosoft.co.th">komsan.s&#64;ecosoft.co.th</a>&gt;</li>
<li>Kevin Khao &lt;<a class="reference external" href="mailto:kkh&#64;360erp.com">kkh&#64;360erp.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
4 changes: 2 additions & 2 deletions account_billing/tests/test_account_billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setUpClass(cls):
cls.partner_agrolait = cls.env.ref("base.res_partner_2")
cls.partner_china_exp = cls.env.ref("base.res_partner_3")
cls.product = cls.env.ref("product.product_product_4")
cls.currency_eur = cls.env["res.currency"].browse(1)
cls.currency_eur = cls.env.ref("base.EUR")
cls.currency_eur.active = True
cls.currency_usd_id = cls.env.ref("base.USD").id
cls.currency_eur_id = cls.env.ref("base.EUR").id
Expand All @@ -46,7 +46,7 @@ def setUpClass(cls):
"=",
"income",
),
("company_id", "=", cls.env.company.id),
("company_ids", "=", cls.env.company.id),
],
limit=1,
)
Expand Down
21 changes: 9 additions & 12 deletions account_billing/views/account_billing_views.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<odoo>
<record id="view_account_billing_tree" model="ir.ui.view">
<field name="name">account.billing.tree</field>
<field name="name">account.billing.list</field>
<field name="model">account.billing</field>
<field name="arch" type="xml">
<tree
<list
decoration-info="state == 'draft'"
decoration-muted="state == 'cancel'"
edit="false"
Expand All @@ -20,14 +20,14 @@
decoration-info="state == 'draft'"
decoration-danger="state == 'cancel'"
/>
</tree>
</list>
</field>
</record>
<record id="view_account_supplier_billing_tree" model="ir.ui.view">
<field name="name">account.supplier.billing.tree</field>
<field name="name">account.supplier.billing.list</field>
<field name="model">account.billing</field>
<field name="arch" type="xml">
<tree
<list
decoration-info="state == 'draft'"
decoration-muted="state == 'cancel'"
edit="false"
Expand All @@ -44,7 +44,7 @@
decoration-info="state == 'draft'"
decoration-danger="state == 'cancel'"
/>
</tree>
</list>
</field>
</record>
<record id="view_billing_search" model="ir.ui.view">
Expand Down Expand Up @@ -201,7 +201,7 @@
invisible="state != 'draft'"
/>
<field name="billing_line_ids" readonly="state != 'draft'">
<tree name="billing" create="0" editable="bottom">
<list name="billing" create="0" editable="bottom">
<field name="move_id" invisible="1" />
<field name="name" />
<field name="invoice_date" />
Expand Down Expand Up @@ -233,7 +233,7 @@
decoration-danger="payment_state == 'reversed'"
decoration-warning="payment_state == 'in_payment'"
/>
</tree>
</list>
</field>
<group>
<group>
Expand All @@ -250,10 +250,7 @@
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
</div>
<div class="oe_chatter" />
</form>
</field>
</record>
Expand Down

0 comments on commit dc9b777

Please sign in to comment.