diff options
| author | Pierre Masereel <pim@odoo.com> | 2019-09-30 08:02:13 +0000 |
|---|---|---|
| committer | Pierre Masereel <pim@odoo.com> | 2019-10-01 10:02:50 +0000 |
| commit | 8f91e81065d5c68a8cb04534d51bcf80f01d9565 (patch) | |
| tree | adc443c16404a84c418ede95ffa580a5fd3edf4c /addons | |
| parent | 82e06a9f5086e5417c5371d592c99153db2dcac4 (diff) | |
[FIX] l10n_fr_pos_cert: move sale closing on pos
The report sale closing that was working on journal and takes the sales
total and cumulative total on periods of 'day', 'month' and 'years'. Is
now based on the pos orders and moved to the pos certification module.
closes odoo/odoo#36967
Task-id: 47990
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/l10n_fr/__manifest__.py | 4 | ||||
| -rw-r--r-- | addons/l10n_fr/models/__init__.py | 1 | ||||
| -rw-r--r-- | addons/l10n_fr/security/ir.model.access.csv | 2 | ||||
| -rw-r--r-- | addons/l10n_fr_pos_cert/__manifest__.py | 6 | ||||
| -rw-r--r-- | addons/l10n_fr_pos_cert/data/account_sale_closure_cron.xml (renamed from addons/l10n_fr/data/account_sale_closure_cron.xml) | 0 | ||||
| -rw-r--r-- | addons/l10n_fr_pos_cert/models/__init__.py | 1 | ||||
| -rw-r--r-- | addons/l10n_fr_pos_cert/models/account_closing.py (renamed from addons/l10n_fr/models/account_closing.py) | 30 | ||||
| -rw-r--r-- | addons/l10n_fr_pos_cert/security/account_closing_intercompany.xml (renamed from addons/l10n_fr/security/account_closing_intercompany.xml) | 0 | ||||
| -rw-r--r-- | addons/l10n_fr_pos_cert/security/ir.model.access.csv | 2 | ||||
| -rw-r--r-- | addons/l10n_fr_pos_cert/views/account_sale_closure.xml (renamed from addons/l10n_fr/views/account_sale_closure.xml) | 4 | ||||
| -rw-r--r-- | addons/l10n_fr_pos_cert/views/pos_inalterability_menuitem.xml | 2 |
11 files changed, 30 insertions, 22 deletions
diff --git a/addons/l10n_fr/__manifest__.py b/addons/l10n_fr/__manifest__.py index 4b10e78820d..94c8c05855e 100644 --- a/addons/l10n_fr/__manifest__.py +++ b/addons/l10n_fr/__manifest__.py @@ -46,10 +46,6 @@ configuration of their taxes and fiscal positions manually. 'data/account_fiscal_position_template_data.xml', 'data/account_reconcile_model_template.xml', 'data/account_chart_template_configure_data.xml', - 'data/account_sale_closure_cron.xml', - 'views/account_sale_closure.xml', - 'security/ir.model.access.csv', - 'security/account_closing_intercompany.xml', ], 'post_init_hook': '_l10n_fr_post_init_hook', } diff --git a/addons/l10n_fr/models/__init__.py b/addons/l10n_fr/models/__init__.py index a8fff1c9bc8..815ba6b271a 100644 --- a/addons/l10n_fr/models/__init__.py +++ b/addons/l10n_fr/models/__init__.py @@ -4,4 +4,3 @@ from . import l10n_fr from . import account_chart_template from . import res_company -from . import account_closing diff --git a/addons/l10n_fr/security/ir.model.access.csv b/addons/l10n_fr/security/ir.model.access.csv deleted file mode 100644 index a3c5001986d..00000000000 --- a/addons/l10n_fr/security/ir.model.access.csv +++ /dev/null @@ -1,2 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_l10n_fr_account_sale_closing_user,l10n_fr.account.sale.closing.user,l10n_fr.model_account_sale_closing,base.group_user,1,0,0,0
\ No newline at end of file diff --git a/addons/l10n_fr_pos_cert/__manifest__.py b/addons/l10n_fr_pos_cert/__manifest__.py index 9e9dce4d0cf..7d96df708ce 100644 --- a/addons/l10n_fr_pos_cert/__manifest__.py +++ b/addons/l10n_fr_pos_cert/__manifest__.py @@ -26,11 +26,15 @@ The module adds following features: 'auto_install': True, 'application': False, 'data': [ - 'views/pos_inalterability_menuitem.xml', 'views/account_views.xml', 'views/l10n_fr_pos_cert_templates.xml', 'views/pos_views.xml', + 'views/account_sale_closure.xml', + 'views/pos_inalterability_menuitem.xml', 'report/pos_hash_integrity.xml', + 'data/account_sale_closure_cron.xml', + 'security/ir.model.access.csv', + 'security/account_closing_intercompany.xml', ], 'qweb': ['static/src/xml/pos.xml'], 'post_init_hook': '_setup_inalterability', diff --git a/addons/l10n_fr/data/account_sale_closure_cron.xml b/addons/l10n_fr_pos_cert/data/account_sale_closure_cron.xml index ba2bd2f3a4b..ba2bd2f3a4b 100644 --- a/addons/l10n_fr/data/account_sale_closure_cron.xml +++ b/addons/l10n_fr_pos_cert/data/account_sale_closure_cron.xml diff --git a/addons/l10n_fr_pos_cert/models/__init__.py b/addons/l10n_fr_pos_cert/models/__init__.py index 33657992e1c..771f4698144 100644 --- a/addons/l10n_fr_pos_cert/models/__init__.py +++ b/addons/l10n_fr_pos_cert/models/__init__.py @@ -4,3 +4,4 @@ from . import account_bank_statement from . import account_fiscal_position from . import res_company from . import pos +from . import account_closing diff --git a/addons/l10n_fr/models/account_closing.py b/addons/l10n_fr_pos_cert/models/account_closing.py index c498c978ea7..ecc77bac8a6 100644 --- a/addons/l10n_fr/models/account_closing.py +++ b/addons/l10n_fr_pos_cert/models/account_closing.py @@ -6,6 +6,7 @@ from odoo import models, api, fields from odoo.fields import Datetime as FieldDateTime from odoo.tools.translate import _ from odoo.exceptions import UserError +from odoo.osv.expression import AND class AccountClosing(models.Model): @@ -27,8 +28,8 @@ class AccountClosing(models.Model): total_interval = fields.Monetary(string="Period Total", help='Total in receivable accounts during the interval, excluding overlapping periods', readonly=True, required=True) cumulative_total = fields.Monetary(string="Cumulative Grand Total", help='Total in receivable accounts since the beginnig of times', readonly=True, required=True) sequence_number = fields.Integer('Sequence #', readonly=True, required=True) - last_move_id = fields.Many2one('account.move', string='Last journal entry', help='Last Journal entry included in the grand total', readonly=True) - last_move_hash = fields.Char(string='Last journal entry\'s inalteralbility hash', readonly=True) + last_order_id = fields.Many2one('pos.order', string='Last Pos Order', help='Last Pos order included in the grand total', readonly=True) + last_order_hash = fields.Char(string='Last Order entry\'s inalteralbility hash', readonly=True) currency_id = fields.Many2one('res.currency', string='Currency', help="The company's currency", readonly=True, related='company_id.currency_id', store=True) def _query_for_aml(self, company, first_move_sequence_number, date_start): @@ -77,28 +78,35 @@ class AccountClosing(models.Model): ('frequency', '=', frequency), ('company_id', '=', company.id)], limit=1, order='sequence_number desc') - first_move = self.env['account.move'] + first_order = self.env['pos.order'] date_start = interval_dates['interval_from'] cumulative_total = 0 if previous_closing: - first_move = previous_closing.last_move_id + first_order = previous_closing.last_order_id date_start = previous_closing.create_date cumulative_total += previous_closing.cumulative_total - aml_aggregate = self._query_for_aml(company, first_move.secure_sequence_number, date_start) + domain = [('company_id', '=', company.id), ('state', 'in', ('paid', 'done', 'invoiced'))] + if first_order.l10n_fr_secure_sequence_number is not False and first_order.l10n_fr_secure_sequence_number is not None: + domain = AND([domain, [('l10n_fr_secure_sequence_number', '>', first_order.l10n_fr_secure_sequence_number)]]) + elif date_start: + #the first time we compute the closing, we consider only from the installation of the module + domain = AND([domain, [('date_order', '>=', date_start)]]) + + orders = self.env['pos.order'].search(domain, order='date_order desc') - total_interval = aml_aggregate['balance'] or 0 + total_interval = sum(orders.mapped('amount_total')) cumulative_total += total_interval # We keep the reference to avoid gaps (like daily object during the weekend) - last_move = first_move - if aml_aggregate['move_ids']: - last_move = last_move.browse(aml_aggregate['move_ids'][0]) + last_order = first_order + if orders: + last_order = orders[0] return {'total_interval': total_interval, 'cumulative_total': cumulative_total, - 'last_move_id': last_move.id, - 'last_move_hash': last_move.inalterable_hash, + 'last_order_id': last_order.id, + 'last_order_hash': last_order.l10n_fr_secure_sequence_number, 'date_closing_stop': interval_dates['date_stop'], 'date_closing_start': date_start, 'name': interval_dates['name_interval'] + ' - ' + interval_dates['date_stop'][:10]} diff --git a/addons/l10n_fr/security/account_closing_intercompany.xml b/addons/l10n_fr_pos_cert/security/account_closing_intercompany.xml index a316014794e..a316014794e 100644 --- a/addons/l10n_fr/security/account_closing_intercompany.xml +++ b/addons/l10n_fr_pos_cert/security/account_closing_intercompany.xml diff --git a/addons/l10n_fr_pos_cert/security/ir.model.access.csv b/addons/l10n_fr_pos_cert/security/ir.model.access.csv new file mode 100644 index 00000000000..a2553eb8de9 --- /dev/null +++ b/addons/l10n_fr_pos_cert/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_l10n_fr_pos_cert_account_sale_closing_user,l10n_fr_pos_cert.account.sale.closing.user,l10n_fr_pos_cert.model_account_sale_closing,base.group_user,1,0,0,0 diff --git a/addons/l10n_fr/views/account_sale_closure.xml b/addons/l10n_fr_pos_cert/views/account_sale_closure.xml index e33549ffb4a..24e4c14cd71 100644 --- a/addons/l10n_fr/views/account_sale_closure.xml +++ b/addons/l10n_fr_pos_cert/views/account_sale_closure.xml @@ -37,8 +37,8 @@ <group> <field name="total_interval"/> <field name="cumulative_total"/> - <field name="last_move_id" groups="account.group_account_user"/> - <field name="last_move_hash" groups="account.group_account_user"/> + <field name="last_order_id" groups="account.group_account_user"/> + <field name="last_order_hash" groups="account.group_account_user"/> </group> <group> <field name="company_id" groups="base.group_multi_company"/> diff --git a/addons/l10n_fr_pos_cert/views/pos_inalterability_menuitem.xml b/addons/l10n_fr_pos_cert/views/pos_inalterability_menuitem.xml index efaab7ef24f..3557204c8a3 100644 --- a/addons/l10n_fr_pos_cert/views/pos_inalterability_menuitem.xml +++ b/addons/l10n_fr_pos_cert/views/pos_inalterability_menuitem.xml @@ -18,6 +18,6 @@ </field> </record> <menuitem id="pos_fr_statements_menu" name="French Statements" parent="point_of_sale.menu_point_rep" sequence="9" /> - <menuitem action="l10n_fr.action_list_view_account_sale_closing" id="menu_account_closing" parent="pos_fr_statements_menu" sequence="80"/> + <menuitem action="l10n_fr_pos_cert.action_list_view_account_sale_closing" id="menu_account_closing" parent="pos_fr_statements_menu" sequence="80"/> <menuitem action="l10n_fr_pos_cert.action_check_pos_hash_integrity" id="menu_check_move_integrity_reporting" parent="pos_fr_statements_menu" sequence="90"/> </odoo> |
