2
0

[15.0][MIG] account_spread_cost_revenue

This commit is contained in:
Saran440 2023-05-29 10:38:12 +07:00 committed by Andrea Stirpe
parent 0fdbf6f02c
commit f3cd6619e1
9 changed files with 48 additions and 55 deletions

View File

@ -4,7 +4,7 @@
{ {
"name": "Cost-Revenue Spread", "name": "Cost-Revenue Spread",
"summary": "Spread costs and revenues over a custom period", "summary": "Spread costs and revenues over a custom period",
"version": "14.0.1.0.0", "version": "15.0.1.0.0",
"development_status": "Beta", "development_status": "Beta",
"author": "Onestein,Odoo Community Association (OCA)", "author": "Onestein,Odoo Community Association (OCA)",
"maintainers": ["astirpe"], "maintainers": ["astirpe"],
@ -12,6 +12,12 @@
"website": "https://github.com/OCA/account-financial-tools", "website": "https://github.com/OCA/account-financial-tools",
"category": "Accounting & Finance", "category": "Accounting & Finance",
"depends": ["account"], "depends": ["account"],
"assets": {
"web.assets_backend": [
"/account_spread_cost_revenue/static/src/scss/account_spread.scss",
"/account_spread_cost_revenue/static/src/js/account_spread.js",
],
},
"data": [ "data": [
"security/ir.model.access.csv", "security/ir.model.access.csv",
"security/account_spread_security.xml", "security/account_spread_security.xml",
@ -19,7 +25,6 @@
"views/account_move.xml", "views/account_move.xml",
"views/res_company.xml", "views/res_company.xml",
"views/account_spread_template.xml", "views/account_spread_template.xml",
"templates/assets.xml",
"wizards/account_spread_invoice_line_link_wizard.xml", "wizards/account_spread_invoice_line_link_wizard.xml",
"data/spread_cron.xml", "data/spread_cron.xml",
], ],

View File

@ -97,7 +97,9 @@ class AccountMoveLine(models.Model):
def _check_spread_reconcile_validity(self): def _check_spread_reconcile_validity(self):
# Improve error messages of standard Odoo # Improve error messages of standard Odoo
reconciled_lines = self.filtered(lambda l: l.reconciled) reconciled_lines = self.filtered(lambda l: l.reconciled)
msg_line = _("Move line: %s (%s), account code: %s\n") msg_line = _(
"Move line: %(line_id)s (%(line_name)s), account code: %(account_code)s\n"
)
if reconciled_lines: if reconciled_lines:
msg = _("Cannot reconcile entries that are already reconciled:\n") msg = _("Cannot reconcile entries that are already reconciled:\n")
for line in reconciled_lines: for line in reconciled_lines:
@ -146,10 +148,9 @@ class AccountMoveLine(models.Model):
elif len(template) > 1: elif len(template) > 1:
raise UserError( raise UserError(
_( _(
"Too many auto spread templates (%s) matched with the " "Too many auto spread templates ({}) matched with the "
"invoice line, %s" "invoice line, {}"
) ).format(len(template), line.display_name)
% (len(template), line.display_name)
) )
# Found auto spread template for this invoice line, create it # Found auto spread template for this invoice line, create it
wizard = self.env["account.spread.invoice.line.link.wizard"].new( wizard = self.env["account.spread.invoice.line.link.wizard"].new(

View File

@ -520,7 +520,7 @@ class AccountSpread(models.Model):
"<a href=# data-oe-model=account.move " "<a href=# data-oe-model=account.move "
"data-oe-id=%d>%s</a>" % (spread.invoice_id.id, _("Invoice")) "data-oe-id=%d>%s</a>" % (spread.invoice_id.id, _("Invoice"))
) )
msg_body = _("Unlinked invoice line '%s' (view %s).") % ( msg_body = _("Unlinked invoice line '{}' (view {}).").format(
spread.invoice_line_id.name, spread.invoice_line_id.name,
inv_link, inv_link,
) )
@ -529,7 +529,7 @@ class AccountSpread(models.Model):
"<a href=# data-oe-model=account.spread " "<a href=# data-oe-model=account.spread "
"data-oe-id=%d>%s</a>" % (spread.id, _("Spread")) "data-oe-id=%d>%s</a>" % (spread.id, _("Spread"))
) )
msg_body = _("Unlinked '%s' (invoice line %s).") % ( msg_body = _("Unlinked '{}' (invoice line {}).").format(
spread_link, spread_link,
spread.invoice_line_id.name, spread.invoice_line_id.name,
) )
@ -578,7 +578,7 @@ class AccountSpread(models.Model):
return return
ctx = dict(self.env.context, skip_unique_sequence_number=True) ctx = dict(self.env.context, skip_unique_sequence_number=True)
if self.company_id.force_move_auto_post or self.move_line_auto_post: if self.company_id.force_move_auto_post or self.move_line_auto_post:
moves.with_context(ctx).action_post() moves.with_context(**ctx).action_post()
@api.depends("debit_account_id.deprecated", "credit_account_id.deprecated") @api.depends("debit_account_id.deprecated", "credit_account_id.deprecated")
def _compute_deprecated_accounts(self): def _compute_deprecated_accounts(self):

View File

@ -169,7 +169,9 @@ class AccountSpreadTemplate(models.Model):
) )
if results: if results:
raise UserError( raise UserError(
_("Followings are duplicated combinations,\n\n%s" % "\n".join(results)) _("Followings are duplicated combinations,\n\n{}").format(
"\n".join(results)
)
) )

View File

@ -1,2 +1,3 @@
* Andrea Stirpe <a.stirpe@onestein.nl> * Andrea Stirpe <a.stirpe@onestein.nl>
* Kitti U. <kittiu@ecosoft.co.th> * Kitti U. <kittiu@ecosoft.co.th>
* Saran Lim. <saranl@ecosoft.co.th>

View File

@ -1,7 +1,7 @@
Define Spread Costs/Revenues Board Define Spread Costs/Revenues Board
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Under Invoicing -> Adviser -> Accounting Entries -> Spread Costs/Revenues, create a new spread board. Under Invoicing -> Accounting -> Miscellaneous -> Spread Costs/Revenues, create a new spread board.
Complete the definition of the spreading criteria, by setting the the fields: Complete the definition of the spreading criteria, by setting the the fields:
@ -16,7 +16,7 @@ Complete the definition of the spreading criteria, by setting the the fields:
.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/12.0/account_spread_cost_revenue/static/description/spread.png .. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/12.0/account_spread_cost_revenue/static/description/spread.png
:alt: Create a new spread board :alt: Create a new spread board
Click on the button on the top-left to calculate the spread lines. Click on the "Recalculate unposted lines" button on the top-left to calculate the spread lines.
.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/12.0/account_spread_cost_revenue/static/description/create_spread.png .. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/12.0/account_spread_cost_revenue/static/description/create_spread.png
:alt: The spreading board is defined :alt: The spreading board is defined

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<odoo> <odoo noupdate="1">
<data noupdate="1">
<record id="account_spread_multi_company_rule" model="ir.rule"> <record id="account_spread_multi_company_rule" model="ir.rule">
<field name="name">Account Spread multi-company</field> <field name="name">Account Spread multi-company</field>
<field ref="model_account_spread" name="model_id" /> <field ref="model_account_spread" name="model_id" />
@ -25,5 +24,4 @@
name="domain_force" name="domain_force"
>['|',('company_id','=',False),('company_id', 'in', company_ids)]</field> >['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
</record> </record>
</data>
</odoo> </odoo>

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="assets_backend" name="account spread" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link
rel="stylesheet"
href="/account_spread_cost_revenue/static/src/scss/account_spread.scss"
/>
<script
type="text/javascript"
src="/account_spread_cost_revenue/static/src/js/account_spread.js"
/>
</xpath>
</template>
</odoo>

View File

@ -798,6 +798,7 @@ class TestAccountInvoiceSpread(common.TransactionCase):
"date": fields.Date.today(), "date": fields.Date.today(),
"reason": "no reason", "reason": "no reason",
"refund_method": "refund", "refund_method": "refund",
"journal_id": self.vendor_bill.journal_id.id,
} }
) )
) )