New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD] account,*: Merge account.invoice & account.move #33797
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,9 @@ class PortalAccount(CustomerPortal): | |
|
||
def _prepare_portal_layout_values(self): | ||
values = super(PortalAccount, self)._prepare_portal_layout_values() | ||
invoice_count = request.env['account.invoice'].search_count([]) | ||
invoice_count = request.env['account.move'].search_count([ | ||
('type', 'in', ('out_invoice', 'in_invoice', 'out_refund', 'in_refund', 'out_receipt', 'in_receipt')), | ||
]) | ||
values['invoice_count'] = invoice_count | ||
return values | ||
|
||
|
@@ -29,13 +31,13 @@ def _invoice_get_page_view_values(self, invoice, access_token, **kwargs): | |
@http.route(['/my/invoices', '/my/invoices/page/<int:page>'], type='http', auth="user", website=True) | ||
def portal_my_invoices(self, page=1, date_begin=None, date_end=None, sortby=None, **kw): | ||
values = self._prepare_portal_layout_values() | ||
AccountInvoice = request.env['account.invoice'] | ||
AccountInvoice = request.env['account.move'] | ||
|
||
domain = [] | ||
domain = [('type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, call to common function to get domain |
||
|
||
searchbar_sortings = { | ||
'date': {'label': _('Invoice Date'), 'order': 'date_invoice desc'}, | ||
'duedate': {'label': _('Due Date'), 'order': 'date_due desc'}, | ||
'date': {'label': _('Invoice Date'), 'order': 'invoice_date desc'}, | ||
'duedate': {'label': _('Due Date'), 'order': 'invoice_date_due desc'}, | ||
'name': {'label': _('Reference'), 'order': 'name desc'}, | ||
'state': {'label': _('Status'), 'order': 'state'}, | ||
} | ||
|
@@ -44,7 +46,7 @@ def portal_my_invoices(self, page=1, date_begin=None, date_end=None, sortby=None | |
sortby = 'date' | ||
order = searchbar_sortings[sortby]['order'] | ||
|
||
archive_groups = self._get_archive_groups('account.invoice', domain) | ||
archive_groups = self._get_archive_groups('account.move', domain) | ||
if date_begin and date_end: | ||
domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] | ||
|
||
|
@@ -77,7 +79,7 @@ def portal_my_invoices(self, page=1, date_begin=None, date_end=None, sortby=None | |
@http.route(['/my/invoices/<int:invoice_id>'], type='http', auth="public", website=True) | ||
def portal_my_invoice_detail(self, invoice_id, access_token=None, report_type=None, download=False, **kw): | ||
try: | ||
invoice_sudo = self._document_check_access('account.invoice', invoice_id, access_token) | ||
invoice_sudo = self._document_check_access('account.move', invoice_id, access_token) | ||
except (AccessError, MissingError): | ||
return request.redirect('/my') | ||
|
||
|
@@ -88,7 +90,7 @@ def portal_my_invoice_detail(self, invoice_id, access_token=None, report_type=No | |
acquirers = values.get('acquirers') | ||
if acquirers: | ||
country_id = values.get('partner_id') and values.get('partner_id')[0].country_id.id | ||
values['acq_extra_fees'] = acquirers.get_acquirer_extra_fees(invoice_sudo.residual, invoice_sudo.currency_id, country_id) | ||
values['acq_extra_fees'] = acquirers.get_acquirer_extra_fees(invoice_sudo.amount_residual, invoice_sudo.currency_id, country_id) | ||
|
||
return request.render("account.portal_invoice_page", values) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -553,8 +553,6 @@ def _get_bank_statements_available_sources(self): | |
domain=[('deprecated', '=', False)], help="It acts as a default account for debit amount") | ||
update_posted = fields.Boolean(string='Allow Cancelling Entries', | ||
help="Check this box if you want to allow the cancellation the entries related to this journal or of the invoice related to this journal") | ||
group_invoice_lines = fields.Boolean(string='Group Invoice Lines', | ||
help="If this box is checked, the system will try to group the accounting lines when generating them from invoices.") | ||
sequence_id = fields.Many2one('ir.sequence', string='Entry Sequence', | ||
help="This field contains the information related to the numbering of the journal entries of this journal.", required=True, copy=False) | ||
refund_sequence_id = fields.Many2one('ir.sequence', string='Credit Note Entry Sequence', | ||
|
@@ -738,7 +736,7 @@ def _update_mail_alias(self, vals): | |
if self.alias_id: | ||
self.alias_id.write(alias_values) | ||
else: | ||
self.alias_id = self.env['mail.alias'].with_context(alias_model_name='account.invoice', | ||
self.alias_id = self.env['mail.alias'].with_context(alias_model_name='account.move', | ||
alias_parent_model_name='account.journal').create(alias_values) | ||
|
||
if vals.get('alias_name'): | ||
|
@@ -1179,17 +1177,6 @@ def onchange_price_include(self): | |
if self.price_include: | ||
self.include_base_amount = True | ||
|
||
def get_grouping_key(self, invoice_tax_val): | ||
""" Returns a string that will be used to group account.invoice.tax sharing the same properties""" | ||
self.ensure_one() | ||
return str(invoice_tax_val['tax_id']) + '-' + \ | ||
str(invoice_tax_val.get('tax_repartition_line_id')) + '-' + \ | ||
str(invoice_tax_val['account_id']) + '-' + \ | ||
str(invoice_tax_val['account_analytic_id']) + '-' + \ | ||
str(invoice_tax_val.get('analytic_tag_ids', [])) + '-' + \ | ||
str(invoice_tax_val.get('tax_ids') or []) + '-' + \ | ||
str(invoice_tax_val.get('tag_ids') or []) | ||
|
||
def _compute_amount(self, base_amount, price_unit, quantity=1.0, product=None, partner=None): | ||
""" Returns the amount of a single tax. base_amount is the actual amount on which the tax is applied, which is | ||
price_unit * quantity eventually affected by previous taxes (if tax is include_base_amount XOR price_include) | ||
|
@@ -1210,7 +1197,7 @@ def _compute_amount(self, base_amount, price_unit, quantity=1.0, product=None, p | |
else: | ||
return quantity * self.amount | ||
|
||
price_include = self._context['force_price_include'] if 'force_price_include' in self._context else self.price_include | ||
price_include = self._context.get('force_price_include', self.price_include) | ||
|
||
# base * (1 + tax_amount) = new_base | ||
if self.amount_type == 'percent' and not price_include: | ||
|
@@ -1254,12 +1241,15 @@ def get_tax_tags(self, is_refund, repartition_type): | |
return rep_lines.filtered(lambda x: x.repartition_type == repartition_type).mapped('tag_ids') | ||
|
||
@api.multi | ||
def compute_all(self, price_unit, currency=None, quantity=1.0, product=None, partner=None, is_refund=False): | ||
def compute_all(self, price_unit, currency=None, quantity=1.0, product=None, partner=None, is_refund=False, handle_price_include=True): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be good to add something in the dosctring about this parameter ; so that we understand its use directly |
||
""" Returns all information required to apply taxes (in self + their children in case of a tax group). | ||
We consider the sequence of the parent for group of taxes. | ||
Eg. considering letters as taxes and alphabetic order as sequence : | ||
[G, B([A, D, F]), E, C] will be computed as [A, D, F, C, E, G] | ||
|
||
'handle_price_include' is used when we need to ignore all tax included in price. If False, it means the | ||
amount passed to this method will be considered as the base of all computations. | ||
|
||
RETURN: { | ||
'total_excluded': 0.0, # Total without taxes | ||
'total_included': 0.0, # Total with taxes | ||
|
@@ -1362,28 +1352,29 @@ def recompute_base(base_amount, fixed_amount, percent_amount, division_amount): | |
incl_fixed_amount = incl_percent_amount = incl_division_amount = 0 | ||
# Store the tax amounts we compute while searching for the total_excluded | ||
cached_tax_amounts = {} | ||
for tax in reversed(taxes): | ||
if tax.include_base_amount: | ||
base = recompute_base(base, incl_fixed_amount, incl_percent_amount, incl_division_amount) | ||
incl_fixed_amount = incl_percent_amount = incl_division_amount = 0 | ||
store_included_tax_total = True | ||
if tax.price_include: | ||
if tax.amount_type == 'percent': | ||
incl_percent_amount += tax.amount | ||
elif tax.amount_type == 'division': | ||
incl_division_amount += tax.amount | ||
elif tax.amount_type == 'fixed': | ||
incl_fixed_amount += quantity * tax.amount | ||
else: | ||
# tax.amount_type == other (python) | ||
tax_amount = tax._compute_amount(base, price_unit, quantity, product, partner) | ||
incl_fixed_amount += tax_amount | ||
# Avoid unecessary re-computation | ||
cached_tax_amounts[i] = tax_amount | ||
if store_included_tax_total: | ||
total_included_checkpoints[i] = base | ||
store_included_tax_total = False | ||
i -= 1 | ||
if handle_price_include: | ||
for tax in reversed(taxes): | ||
if tax.include_base_amount: | ||
base = recompute_base(base, incl_fixed_amount, incl_percent_amount, incl_division_amount) | ||
incl_fixed_amount = incl_percent_amount = incl_division_amount = 0 | ||
store_included_tax_total = True | ||
if tax.price_include: | ||
if tax.amount_type == 'percent': | ||
incl_percent_amount += tax.amount | ||
elif tax.amount_type == 'division': | ||
incl_division_amount += tax.amount | ||
elif tax.amount_type == 'fixed': | ||
incl_fixed_amount += quantity * tax.amount | ||
else: | ||
# tax.amount_type == other (python) | ||
tax_amount = tax._compute_amount(base, price_unit, quantity, product, partner) | ||
incl_fixed_amount += tax_amount | ||
# Avoid unecessary re-computation | ||
cached_tax_amounts[i] = tax_amount | ||
if store_included_tax_total: | ||
total_included_checkpoints[i] = base | ||
store_included_tax_total = False | ||
i -= 1 | ||
|
||
total_excluded = recompute_base(base, incl_fixed_amount, incl_percent_amount, incl_division_amount) | ||
|
||
|
@@ -1438,8 +1429,8 @@ def recompute_base(base_amount, fixed_amount, percent_amount, division_amount): | |
'price_include': tax.price_include, | ||
'tax_exigibility': tax.tax_exigibility, | ||
'tax_repartition_line_id': repartition_line.id, | ||
'tag_ids': [(6, False, (repartition_line.tag_ids + subsequent_tags).ids)], | ||
'tax_ids': [(6, False, subsequent_taxes.ids)] | ||
'tag_ids': (repartition_line.tag_ids + subsequent_tags).ids, | ||
'tax_ids': subsequent_taxes.ids, | ||
}) | ||
|
||
total_amount += line_amount | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For get domain can call to function??, see #22121
DIFF c3e3770