-
- The Balance Sheet account used for the spreading.
This account is the counterpart of the account in the invoice line.
+
+
+
+
+
+ The Balance Sheet account used for the spreading.
This account is the counterpart of the account in the invoice line.
-
- The Expense account in the vendor bill line.
Usually the same account of the vendor bill line.
+
+ The Expense account in the vendor bill line.
Usually the same account of the vendor bill line.
-
-
- The Balance Sheet account.
This is the account in the invoice line.
+
+
+ The Balance Sheet account.
This is the account in the invoice line.
-
- The Expense account used for the spreading.
This account is the counterpart of the account of the vendor bill line.
+
+ The Expense account used for the spreading.
This account is the counterpart of the account of the vendor bill line.
-
-
+
+
This account in deprecated! The reconciliation will be NOT possible.
-
-
-
-
-
- The Revenue account in the invoice line.
Usually the same account of the invoice line.
+
+
+
+
+
+ The Revenue account in the invoice line.
Usually the same account of the invoice line.
-
- The Balance Sheet account used for the spreading.
This account is the counterpart of the account in the vendor bill line.
+
+ The Balance Sheet account used for the spreading.
This account is the counterpart of the account in the vendor bill line.
-
-
- The Revenue account used for the spreading.
This account is the counterpart of the account of the invoice line.
+
+
+ The Revenue account used for the spreading.
This account is the counterpart of the account of the invoice line.
-
- The Balance Sheet account.
This is the account in the vendor bill line.
+
+ The Balance Sheet account.
This is the account in the vendor bill line.
-
-
+
+
This account in deprecated! The reconciliation will be NOT possible.
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
account.spread
@@ -181,44 +371,45 @@
1
-
+
-
+
-
account.spread
-
-
+
+
-
account.spread
-
-
+
+
-
Spread Costs/Revenues
account.spread
form
tree,form
-
+
-
-
-
+
diff --git a/account_spread_cost_revenue/views/account_spread_template.xml b/account_spread_cost_revenue/views/account_spread_template.xml
index 3eebe57e..eaf9002d 100644
--- a/account_spread_cost_revenue/views/account_spread_template.xml
+++ b/account_spread_cost_revenue/views/account_spread_template.xml
@@ -1,6 +1,5 @@
-
+
-
account.spread.template
@@ -9,68 +8,94 @@
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
Automatically use this spread template on invoice validation for invoice lines using below product and/or account and/or analytic,
-
+
-
-
-
-
+
+
+
+
-
account.spread.template
-
-
-
-
+
+
+
+
-
Spread Templates
account.spread.template
form
tree,form
-
+
-
-
-
+
diff --git a/account_spread_cost_revenue/views/res_company.xml b/account_spread_cost_revenue/views/res_company.xml
index d09fbba6..f6398596 100644
--- a/account_spread_cost_revenue/views/res_company.xml
+++ b/account_spread_cost_revenue/views/res_company.xml
@@ -1,34 +1,42 @@
-
+
-
res.company
-
+
-
+
-
+
-
+
-
-
+
+
-
diff --git a/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.py b/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.py
index 81b0c16a..cc4cceb2 100644
--- a/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.py
+++ b/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.py
@@ -5,90 +5,85 @@ from odoo import _, api, fields, models
class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
- _name = 'account.spread.invoice.line.link.wizard'
- _description = 'Account Spread Invoice Line Link Wizard'
+ _name = "account.spread.invoice.line.link.wizard"
+ _description = "Account Spread Invoice Line Link Wizard"
def _selection_spread_action_type(self):
base_selection = [
- ('template', _('Create from spread template')),
- ('new', _('Create new spread board'))
+ ("template", _("Create from spread template")),
+ ("new", _("Create new spread board")),
]
- if not self.env.context.get('allow_spread_planning'):
+ if not self.env.context.get("allow_spread_planning"):
return base_selection
link_selection = [
- ('link', _('Link to existing spread board')),
+ ("link", _("Link to existing spread board")),
]
return link_selection + base_selection
def _selection_default_spread_action_type(self):
- if not self.env.context.get('allow_spread_planning'):
- return 'template'
- return 'link'
+ if not self.env.context.get("allow_spread_planning"):
+ return "template"
+ return "link"
invoice_line_id = fields.Many2one(
- 'account.invoice.line',
- string='Invoice Line',
+ "account.invoice.line",
+ string="Invoice Line",
readonly=True,
required=True,
- ondelete='cascade')
- invoice_id = fields.Many2one(
- related='invoice_line_id.invoice_id',
- readonly=True)
- invoice_type = fields.Selection([
- ('out_invoice', 'Customer Invoice'),
- ('in_invoice', 'Vendor Bill'),
- ('out_refund', 'Customer Credit Note'),
- ('in_refund', 'Vendor Credit Note')],
- compute='_compute_invoice_type',
- store=True)
- spread_type = fields.Selection([
- ('sale', 'Customer'),
- ('purchase', 'Supplier')],
- compute='_compute_invoice_type',
- store=True)
- spread_id = fields.Many2one(
- 'account.spread',
- string='Spread Board')
- company_id = fields.Many2one(
- 'res.company',
- string='Company',
- required=True)
+ ondelete="cascade",
+ )
+ invoice_id = fields.Many2one(related="invoice_line_id.invoice_id", readonly=True)
+ invoice_type = fields.Selection(
+ [
+ ("out_invoice", "Customer Invoice"),
+ ("in_invoice", "Vendor Bill"),
+ ("out_refund", "Customer Credit Note"),
+ ("in_refund", "Vendor Credit Note"),
+ ],
+ compute="_compute_invoice_type",
+ store=True,
+ )
+ spread_type = fields.Selection(
+ [("sale", "Customer"), ("purchase", "Supplier")],
+ compute="_compute_invoice_type",
+ store=True,
+ )
+ spread_id = fields.Many2one("account.spread", string="Spread Board")
+ company_id = fields.Many2one("res.company", string="Company", required=True)
spread_action_type = fields.Selection(
selection=_selection_spread_action_type,
- default=_selection_default_spread_action_type)
- template_id = fields.Many2one(
- 'account.spread.template',
- string='Spread Template')
+ default=_selection_default_spread_action_type,
+ )
+ template_id = fields.Many2one("account.spread.template", string="Spread Template")
use_invoice_line_account = fields.Boolean(
string="Use invoice line's account",
help="Use invoice line's account as Balance sheet / spread account.\n"
- "In this case, user need to select expense/revenue account too.")
+ "In this case, user need to select expense/revenue account too.",
+ )
spread_account_id = fields.Many2one(
- 'account.account',
- string='Balance sheet account / Spread account',
- store=True)
+ "account.account", string="Balance sheet account / Spread account", store=True
+ )
exp_rev_account_id = fields.Many2one(
- 'account.account',
- string='Expense/revenue account',
- help="Optional account to overwrite the existing expense/revenue "
- "account")
+ "account.account",
+ string="Expense/revenue account",
+ help="Optional account to overwrite the existing expense/revenue " "account",
+ )
spread_journal_id = fields.Many2one(
- 'account.journal',
- string='Spread Journal',
- store=True)
+ "account.journal", string="Spread Journal", store=True
+ )
- @api.depends('invoice_line_id')
+ @api.depends("invoice_line_id")
def _compute_invoice_type(self):
for wizard in self:
invoice = wizard.invoice_line_id.invoice_id
wizard.invoice_type = invoice.type
- if invoice.type in ['out_invoice', 'out_refund']:
- wizard.spread_type = 'sale'
+ if invoice.type in ["out_invoice", "out_refund"]:
+ wizard.spread_type = "sale"
else:
- wizard.spread_type = 'purchase'
+ wizard.spread_type = "purchase"
- @api.onchange('company_id', 'invoice_type')
+ @api.onchange("company_id", "invoice_type")
def _onchange_spread_journal_account(self):
for wizard in self:
company = wizard.company_id
@@ -96,7 +91,7 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
acc_expense = company.default_spread_expense_account_id
journal_revenue = company.default_spread_revenue_journal_id
journal_expense = company.default_spread_expense_journal_id
- if wizard.invoice_type in ('out_invoice', 'in_refund'):
+ if wizard.invoice_type in ("out_invoice", "in_refund"):
wizard.spread_account_id = acc_revenue
wizard.spread_journal_id = journal_revenue
else:
@@ -108,47 +103,51 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
"""Keep this for making the fields editable"""
pass
- @api.onchange('invoice_type')
+ @api.onchange("invoice_type")
def onchange_invoice_type(self):
domain = [
- ('invoice_id', '=', False),
- ('invoice_type', '=', self.invoice_type),
- ('company_id', '=', self.company_id.id)]
- res = {'domain': {'spread_id': domain}}
+ ("invoice_id", "=", False),
+ ("invoice_type", "=", self.invoice_type),
+ ("company_id", "=", self.company_id.id),
+ ]
+ res = {"domain": {"spread_id": domain}}
return res
- @api.onchange('use_invoice_line_account')
+ @api.onchange("use_invoice_line_account")
def _onchange_user_invoice_line_account(self):
- self.spread_account_id = (self.use_invoice_line_account and
- self.invoice_line_id.account_id or False)
+ self.spread_account_id = (
+ self.use_invoice_line_account and self.invoice_line_id.account_id or False
+ )
self.exp_rev_account_id = False
@api.multi
def confirm(self):
self.ensure_one()
- if self.spread_action_type == 'link':
+ if self.spread_action_type == "link":
if not self.invoice_line_id.spread_id:
self.invoice_line_id.spread_id = self.spread_id
return {
- 'name': _('Spread Details'),
- 'view_type': 'form',
- 'view_mode': 'form',
- 'res_model': 'account.spread',
- 'type': 'ir.actions.act_window',
- 'target': 'current',
- 'readonly': False,
- 'res_id': self.invoice_line_id.spread_id.id,
+ "name": _("Spread Details"),
+ "view_type": "form",
+ "view_mode": "form",
+ "res_model": "account.spread",
+ "type": "ir.actions.act_window",
+ "target": "current",
+ "readonly": False,
+ "res_id": self.invoice_line_id.spread_id.id,
}
- elif self.spread_action_type == 'new':
+ elif self.spread_action_type == "new":
debit_account = credit_account = self.spread_account_id
- if self.invoice_type in ('out_invoice', 'in_refund'):
- credit_account = (self.exp_rev_account_id or
- self.invoice_line_id.account_id)
+ if self.invoice_type in ("out_invoice", "in_refund"):
+ credit_account = (
+ self.exp_rev_account_id or self.invoice_line_id.account_id
+ )
else:
- debit_account = (self.exp_rev_account_id or
- self.invoice_line_id.account_id)
+ debit_account = (
+ self.exp_rev_account_id or self.invoice_line_id.account_id
+ )
analytic_account = self.invoice_line_id.account_analytic_id
analytic_tags = self.invoice_line_id.analytic_tag_ids
@@ -156,27 +155,27 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
use_il_account = self.use_invoice_line_account
return {
- 'name': _('New Spread Board'),
- 'view_type': 'form',
- 'view_mode': 'form',
- 'res_model': 'account.spread',
- 'type': 'ir.actions.act_window',
- 'target': 'current',
- 'readonly': False,
- 'context': {
- 'default_name': self.invoice_line_id.name,
- 'default_invoice_type': self.invoice_type,
- 'default_invoice_line_id': self.invoice_line_id.id,
- 'default_use_invoice_line_account': use_il_account,
- 'default_debit_account_id': debit_account.id,
- 'default_credit_account_id': credit_account.id,
- 'default_journal_id': self.spread_journal_id.id,
- 'default_account_analytic_id': analytic_account.id,
- 'default_analytic_tag_ids': analytic_tags.ids,
- 'default_spread_date': date_invoice,
+ "name": _("New Spread Board"),
+ "view_type": "form",
+ "view_mode": "form",
+ "res_model": "account.spread",
+ "type": "ir.actions.act_window",
+ "target": "current",
+ "readonly": False,
+ "context": {
+ "default_name": self.invoice_line_id.name,
+ "default_invoice_type": self.invoice_type,
+ "default_invoice_line_id": self.invoice_line_id.id,
+ "default_use_invoice_line_account": use_il_account,
+ "default_debit_account_id": debit_account.id,
+ "default_credit_account_id": credit_account.id,
+ "default_journal_id": self.spread_journal_id.id,
+ "default_account_analytic_id": analytic_account.id,
+ "default_analytic_tag_ids": analytic_tags.ids,
+ "default_spread_date": date_invoice,
},
}
- elif self.spread_action_type == 'template':
+ elif self.spread_action_type == "template":
if not self.invoice_line_id.spread_id:
account = self.invoice_line_id.account_id
spread_account_id = False
@@ -190,34 +189,34 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
date_invoice = self.invoice_id.date_invoice
date_invoice = date_invoice or self.template_id.start_date
date_invoice = date_invoice or fields.Date.today()
- spread_vals['spread_date'] = date_invoice
+ spread_vals["spread_date"] = date_invoice
- spread_vals['name'] = ('%s %s') % (
- spread_vals['name'],
- self.invoice_line_id.name
+ spread_vals["name"] = ("%s %s") % (
+ spread_vals["name"],
+ self.invoice_line_id.name,
)
- if spread_vals['invoice_type'] == 'out_invoice':
- spread_vals['credit_account_id'] = account.id
+ if spread_vals["invoice_type"] == "out_invoice":
+ spread_vals["credit_account_id"] = account.id
else:
- spread_vals['debit_account_id'] = account.id
+ spread_vals["debit_account_id"] = account.id
analytic_account = self.invoice_line_id.account_analytic_id
- spread_vals['account_analytic_id'] = analytic_account.id
+ spread_vals["account_analytic_id"] = analytic_account.id
- spread = self.env['account.spread'].create(spread_vals)
+ spread = self.env["account.spread"].create(spread_vals)
analytic_tags = self.invoice_line_id.analytic_tag_ids
spread.analytic_tag_ids = analytic_tags
self.invoice_line_id.spread_id = spread
return {
- 'name': _('Spread Details'),
- 'view_type': 'form',
- 'view_mode': 'form',
- 'res_model': 'account.spread',
- 'type': 'ir.actions.act_window',
- 'target': 'current',
- 'readonly': False,
- 'res_id': self.invoice_line_id.spread_id.id,
+ "name": _("Spread Details"),
+ "view_type": "form",
+ "view_mode": "form",
+ "res_model": "account.spread",
+ "type": "ir.actions.act_window",
+ "target": "current",
+ "readonly": False,
+ "res_id": self.invoice_line_id.spread_id.id,
}
diff --git a/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.xml b/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.xml
index 3eb05fcc..4b1d6e3b 100644
--- a/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.xml
+++ b/account_spread_cost_revenue/wizards/account_spread_invoice_line_link_wizard.xml
@@ -1,34 +1,69 @@
-
+
-
account.spread.invoice.line.link.wizard
-