Compare commits

...

62 Commits

Author SHA1 Message Date
Kev-Roche
515659c069 [14.0][FIX] allow multiple refunds 2024-12-05 20:46:42 +01:00
Alexis de Lattre
f3a6cfade6 [IMP] account_bank_reconciliation_summary_xlsx: add block to have difference et justification (entered by user) 2024-10-23 12:20:26 +02:00
Alexis de Lattre
b8203ae42a [IMP] account_bank_reconciliation_summary_xlsx fine-tune config check 2024-10-22 15:11:01 +02:00
Alexis de Lattre
02d9dee32e [IMP] account_bank_reconciliation_summary_xlsx: use native method to compute account balance 2024-10-22 15:05:32 +02:00
Alexis de Lattre
04b363f8a6 [MIG] mass_mailing_usability to v14 2024-10-22 14:39:45 +02:00
Alexis de Lattre
f3b5f85fc9 [IMP] account_bank_reconciliation_summary_xlsx: support bank journals in currency different than company currency
Update fr translation
2024-10-22 14:34:45 +02:00
Alexis de Lattre
d7f6a2b9f8 [IMP] account_payment_line_manual_account: add support for analytic 2024-10-16 17:13:23 +02:00
Florian
2a0b1342e7 Merge pull request #222 from akretion/14-fix-invoice-update-pdf-unlink
[FIX] account_invoice_update_wizard : avoid stacktrace when no pdf is…
2024-10-10 09:18:57 +02:00
Florian da Costa
db33820a57 [FIX] account_invoice_update_wizard : avoid stacktrace when no pdf is found 2024-10-10 09:12:48 +02:00
Alexis de Lattre
4c067fef09 stock_usability: mig method auto unpack on internal locations from v10 2024-10-01 11:02:26 +02:00
Alexis de Lattre
88452b7930 [IMP] account_usability_akretion: simplify code for invoice attach del upon invoice back to draft 2024-09-30 10:56:47 +02:00
Alexis de Lattre
a6305eb581 [FIX] account_usability: fix deletion of PDF invoice attachment when invoice is back to draft 2024-09-30 09:03:30 +02:00
beau sebastien
d2a8b77c22 Merge pull request #221 from akretion/14.0-purge-pdf
account_invoice_update_wizard: purge existing pdf in attachment after update
2024-09-27 17:25:24 +02:00
Sébastien BEAU
467ce47306 account_invoice_update_wizard: purge existing pdf in attachment after update 2024-09-27 17:11:39 +02:00
Alexis de Lattre
ff0bdc1b8d sale_stock_usability: add method to display delivery order on out invoice report 2024-09-23 21:45:30 +00:00
Alexis de Lattre
254a97edd3 base_usability: Add rcs_siren in company header 2024-09-23 20:56:02 +00:00
Alexis de Lattre
162f0b7874 mrp_usability: add tracking on some fields 2024-09-19 16:04:03 +02:00
Alexis de Lattre
ee8bf2ea17 stock_usability: add script to fix reserved_quantity on quants
Filter-out cancelled move lines shown by "reserved" button on quants
2024-09-19 16:03:08 +02:00
Alexis de Lattre
97c20fed73 mrp_subcontracting_usability: add link to subcontrating production order from stock.move form view 2024-09-19 11:22:59 +02:00
Alexis de Lattre
856bca4ccf account_usability: add search on account in account.move search view 2024-09-17 17:53:28 +02:00
Alexis de Lattre
0d5346d856 Add module account_payment_line_manual_account 2024-09-14 00:13:14 +02:00
Alexis de Lattre
940fe43614 [MIG] partner_products_shortcut from v10 to v14 2024-09-12 22:09:25 +02:00
Alexis de Lattre
4e68c48110 stock_usability: Add product_barcode on orderpoint tree view (optional hide) 2024-09-12 21:28:51 +02:00
Alexis de Lattre
7b8c35a384 Add patch in pos_usability 2024-09-10 23:37:46 +02:00
Alexis de Lattre
0bbda6f265 product_detailed_type: improve compatibility with demo/test data
It's still not perfect yet, in particular when you install the "stock"
module and "product_detailed_type_stock" is not installed yet.
2024-09-05 18:21:59 +02:00
Alexis de Lattre
c7c5d9172b pos_usability: add patch pos-always_open_cashbox.diff 2024-07-15 21:57:09 +02:00
Alexis de Lattre
4655e6b739 base_usability: add 2 patches 2024-07-11 13:04:59 +02:00
Alexis de Lattre
8bd83b0975 mrp_average_cost: avoid crash on bad data 2024-06-25 01:10:51 +02:00
Alexis de Lattre
9367f7006e [FIX] mrp_average_cost: fix bad dependency 2024-06-24 18:31:35 +02:00
Alexis de Lattre
29b8ebb779 account_usability: add invoice currency signed fields
Show these fields as optional in tree view without sum=1
2024-06-24 11:24:22 +02:00
Alexis de Lattre
c33835957d sale_usability: add button to send order acknowledgement
This is a forward port of a v12 commit.
2024-06-24 10:03:13 +02:00
Alexis de Lattre
73e700d2d2 delivery_usability: Move code from stock_packaging_usability_pp to delivery_usability
I don't use stock_packaging_usability_pp from OCA/stock-logistics-tracking because the feature is native since v11 (I didn't figure it out when I ported stock_packaging_usability_ul from v10 to v14 under the new name stock_packaging_usability_ul
I also improved the code to clean it up and use the native field for measured weight
2024-06-04 15:54:22 +02:00
Benoit
5144b039a5 fix report name when deleting attachment invoice with button draft 2024-05-28 11:51:11 +02:00
Florian
0e237d26cb Merge pull request #208 from akretion/14-account-usability-fix-statement-back-to-draft
Revert "account_usability: reset to draft the bank statement do not unreconcile items
2024-05-28 11:26:45 +02:00
Alexis de Lattre
b252bdff34 Add module stock_picking_batch_usability 2024-04-26 17:48:51 +02:00
Alexis de Lattre
550704288d base_usability: add siren and siret in display address method 2024-04-26 10:32:53 +02:00
Alexis de Lattre
320cfff25f stock_usability: always show picking_type_id in picking form view 2024-04-25 15:15:55 +02:00
Alexis de Lattre
26a7a42e8c pos_usability: add pos_type_id on warehouse form view 2024-04-24 13:42:10 +02:00
Alexis de Lattre
3ca4553eb5 product_detailed_type_stock: default product type is 'product' instead of 'consu'
Same behavior as in stock_usability that switch default type to 'product' instead of 'consu'
2024-04-23 21:40:39 +02:00
Alexis de Lattre
309d466374 base_usability + account_usability: give access to acc_holder_name on res.partner.bank (hidden by default) 2024-04-23 21:07:27 +02:00
Florian
61f43e5d02 Merge pull request #209 from akretion/14-adapt-update-entry
[IMP] account_invoice_update_wizard : Adapt wizard view and button to make it usable on accountring entries + small improvements
2024-04-17 11:55:52 +02:00
Alexis de Lattre
6d847dcbe9 mrp_usability: improve mrp reporting
Add product category in reporting
Pivot view by default instead of graph view
Default measure total qty instead of count
2024-04-08 10:34:37 +02:00
Alexis de Lattre
85b4cc25eb sale_down_payment: add ACL 2024-04-05 09:42:54 +02:00
Alexis de Lattre
901a0e5816 mrp_usability: Allow to change the destination location until 'Mark as done'
Native behavior: it is only possible to change the destination stock
location of a production order in draft state.
2024-04-04 16:50:52 +02:00
Alexis de Lattre
569b3fea1a sale_usability: improve tree view of sale.order 2024-04-04 13:51:32 +02:00
Alexis de Lattre
60589b1743 sale_purchase_no_product_template_menu: update entries in account 2024-04-03 17:21:00 +02:00
Alexis de Lattre
5ce7ed3fe7 [IMP] base_usability: improve report header methods on res.company 2024-03-27 11:18:11 +01:00
Alexis de Lattre
ab3562a737 [MIG] mrp_average_cost to v14 2024-03-24 16:08:01 +01:00
Alexis de Lattre
28c6aca721 [MIG] account_invoice_margin from v12 to v14 2024-03-21 18:25:30 +01:00
Alexis de Lattre
b353bb14a5 [MIG] sale_down_payment to v14 2024-03-15 15:23:43 +01:00
Alexis de Lattre
282e7142db sale_usability: track changes in delivered_qty in the chatter
This feature is native in the purchase module in v14. I consider that it
replaces the 3 modules service_line_qty_update_base/service_line_qty_update_purchase/service_line_qty_update_sale
2024-03-14 18:07:52 +01:00
Alexis de Lattre
763928c286 [MIG] rp_no_product_template_menu to v14
Add comment in stock_no_product_template_menu
2024-03-14 17:29:39 +01:00
Alexis de Lattre
4774b879fa [MIG] stock_no_product_template_menu to v14 2024-03-14 17:21:36 +01:00
Alexis de Lattre
18a5c22160 sale_margin_no_onchange: fix digits in field declaration 2024-03-14 17:19:20 +01:00
Alexis de Lattre
8f87df3f3d sale_margin_no_onchange: improve perf by using read_group
Cleanup code
2024-03-14 17:09:53 +01:00
matthieu.saison
6af447974c migration to 14.0 2024-03-14 17:09:53 +01:00
Florian da Costa
46f2e0e01d [IMP] Add bill date (for supplier invoice) and rename bill ref to supplier bill ref to be consistent with name in invoice 2024-03-11 12:29:35 +01:00
Alexis de Lattre
ad8edd00d2 sale_order_route: add route_id in sale.report 2024-02-27 12:51:22 +01:00
Alexis de Lattre
97d57e40eb [FIX] stock_usability: stop adding a field in stock_usability which is defined in mrp ! 2024-02-13 17:00:08 +01:00
Alexis de Lattre
fcf67f4fd9 [MIG] patch for reserved_qty and free_qty from v12 to v14 2024-02-13 16:17:56 +01:00
Florian da Costa
89f81053cd [IMP] account_invoice_update_wizard : rename button for accounting entries + hide invoice specific fields in case of accountring entries 2024-02-12 11:51:15 +01:00
Florian da Costa
b867dd6d01 Revert "account_usability: reset to draft the bank statement do not unreconcile"
This reverts commit 85f8fe5b30.
2024-02-08 11:27:45 +01:00
144 changed files with 2517 additions and 1496 deletions

View File

@@ -1,10 +1,10 @@
# Copyright 2017-2023 Akretion France (http://www.akretion.com/)
# Copyright 2017-2024 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Bank Reconciliation Report",
"version": "14.0.1.0.0",
"version": "14.0.2.0.0",
"license": "AGPL-3",
"author": "Akretion",
"website": "https://github.com/akretion/odoo-usability",

View File

@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-01-13 10:31+0000\n"
"PO-Revision-Date: 2023-01-13 10:31+0000\n"
"POT-Creation-Date: 2024-10-23 10:04+0000\n"
"PO-Revision-Date: 2024-10-23 10:04+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -17,6 +17,7 @@ msgstr ""
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid "Amount"
msgstr "Montant"
@@ -27,6 +28,12 @@ msgstr "Montant"
msgid "Balance %s:"
msgstr "Solde %s :"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid "Bank Balance:"
msgstr "Solde bancaire :"
#. module: account_bank_reconciliation_summary_xlsx
#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard__journal_ids
msgid "Bank Journals"
@@ -49,7 +56,7 @@ msgstr "Rapport de rapprochement bancaire"
#. module: account_bank_reconciliation_summary_xlsx
#: model:ir.model,name:account_bank_reconciliation_summary_xlsx.model_bank_reconciliation_report_wizard
msgid "Bank Reconciliation Report Wizard"
msgstr "Assistant rapport de rapprochement bancaire"
msgstr "Assistant de rapport de rapprochement bancaire"
#. module: account_bank_reconciliation_summary_xlsx
#: model:ir.actions.report,name:account_bank_reconciliation_summary_xlsx.bank_reconciliation_xlsx
@@ -96,17 +103,36 @@ msgstr "Créé le"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid "Currency"
msgstr "Devise"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard__date
#, python-format
msgid "Date"
msgstr ""
msgstr "Date"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid "Description"
msgstr "Description"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid "Difference:"
msgstr "Écart :"
#. module: account_bank_reconciliation_summary_xlsx
#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard__display_name
#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_report_bank_reconciliation_xlsx__display_name
msgid "Display Name"
msgstr ""
msgstr "Nom affiché"
#. module: account_bank_reconciliation_summary_xlsx
#: model:ir.model.fields.selection,name:account_bank_reconciliation_summary_xlsx.selection__bank_reconciliation_report_wizard__move_state__draft_posted
@@ -123,13 +149,13 @@ msgstr "Écritures"
#. module: account_bank_reconciliation_summary_xlsx
#: model_terms:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.bank_reconciliation_report_wizard_form
msgid "Export XLSX"
msgstr ""
msgstr "Exporter en XLSX"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid "Generated on %s"
msgstr "Généré le %s"
msgid "Generated from Odoo on %s by %s"
msgstr "Généré par Odoo le %s par %s"
#. module: account_bank_reconciliation_summary_xlsx
#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard__id
@@ -143,6 +169,18 @@ msgstr ""
msgid "Journal"
msgstr ""
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid "Journal Entry"
msgstr "Pièce"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid "Justification:"
msgstr "Justification :"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
@@ -153,23 +191,17 @@ msgstr "Libellé"
#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard____last_update
#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_report_bank_reconciliation_xlsx____last_update
msgid "Last Modified on"
msgstr ""
msgstr "Dernière modification le"
#. module: account_bank_reconciliation_summary_xlsx
#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard__write_uid
msgid "Last Updated by"
msgstr ""
msgstr "Dernière mise à jour par"
#. module: account_bank_reconciliation_summary_xlsx
#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard__write_date
msgid "Last Updated on"
msgstr ""
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid "Move Number"
msgstr "Numéro de pièce"
msgstr "Dernière mise à jour le"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
@@ -179,10 +211,23 @@ msgstr "Aucun journal de banque sélectionné."
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid "None"
msgstr "Aucun"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid ""
"On bank journal %(journal)s which is configured with currency "
"%(journal_currency)s, the account %(account)s must be configured with the "
"same currency (current account currency: %(account_currency)s)."
msgstr ""
"Sur le journal de banque %(journal)s qui est configuré avec la devise "
"%(journal_currency)s, le compte %(account)s doit être configuré avec la même"
" devise (devise actuelle du compte : %(account_currency)s)."
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
@@ -211,3 +256,13 @@ msgstr "Sous-total :"
#, python-format
msgid "TOTAL:"
msgstr "TOTAL :"
#. module: account_bank_reconciliation_summary_xlsx
#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:0
#, python-format
msgid ""
"The are %(count)s journal items in account %(account)s that have a currency "
"other than %(currency)s or where currency is not set."
msgstr ""
"Il y a %(count)s écritures comptables dans le compte %(account)s qui ont une"
" devise autre que %(currency)s ou dont la devise n'est pas définie."

View File

@@ -1,4 +1,4 @@
# Copyright 2017-2023 Akretion France (http://www.akretion.com/)
# Copyright 2017-2024 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -14,32 +14,19 @@ class BankReconciliationXlsx(models.AbstractModel):
_description = "Bank Reconciliation XLSX Report"
_inherit = "report.report_xlsx.abstract"
def _domain_add_move_state(self, wizard, domain):
if wizard.move_state == 'posted':
domain.append(('parent_state', '=', 'posted'))
elif wizard.move_state == 'draft_posted':
domain.append(('parent_state', 'in', ('draft', 'posted')))
def _get_account_balance(self, account, wizard):
def _prepare_payment_move_lines(self, jdi, account, unreconciled_only=True):
domain = [
('account_id', '=', account.id),
('date', '<=', wizard.date),
('company_id', '=', wizard.company_id.id),
]
self._domain_add_move_state(wizard, domain)
res_rg = self.env['account.move.line'].read_group(domain, ['balance:sum'], [])
account_bal = res_rg and res_rg[0].get('balance', 0.0) or 0.0
return account_bal
def _prepare_payment_move_lines(self, journal, account, wizard, unreconciled_only=True):
domain = [
("company_id", "=", wizard.company_id.id),
("company_id", "=", jdi['company'].id),
("account_id", "=", account.id),
("journal_id", "=", journal.id),
("date", "<=", wizard.date),
("journal_id", "=", jdi['journal'].id),
("date", "<=", jdi['wizard'].date),
]
if jdi['wizard'].move_state == 'posted':
domain.append(('parent_state', '=', 'posted'))
elif jdi['wizard'].move_state == 'draft_posted':
domain.append(('parent_state', 'in', ('draft', 'posted')))
if unreconciled_only:
limit_datetime_naive = datetime.combine(wizard.date, datetime.max.time())
limit_datetime_naive = datetime.combine(jdi['wizard'].date, datetime.max.time())
tz = pytz.timezone(self.env.user.tz)
limit_datetime_aware = tz.localize(limit_datetime_naive)
limit_datetime_utc = limit_datetime_aware.astimezone(pytz.utc)
@@ -47,7 +34,6 @@ class BankReconciliationXlsx(models.AbstractModel):
domain += [
'|', ('full_reconcile_id', '=', False),
('full_reconcile_id.create_date', '>', limit_datetime)]
self._domain_add_move_state(wizard, domain)
mlines = self.env["account.move.line"].search(domain)
res = []
for mline in mlines:
@@ -60,13 +46,18 @@ class BankReconciliationXlsx(models.AbstractModel):
):
cpart.append(line.account_id.code)
counterpart = " ,".join(cpart)
if jdi['currency'] == mline.currency_id:
amount = mline.amount_currency
else:
amount = mline.currency_id._convert(
mline.amount_currency, jdi['currency'], jdi['company'], mline.date)
res.append(
{
"date": mline.date,
"ref": move.ref or "",
"label": mline.name,
"partner": mline.partner_id.display_name or "",
"amount": mline.balance,
"amount": amount,
"move_name": move.name,
"counterpart": counterpart,
}
@@ -74,27 +65,31 @@ class BankReconciliationXlsx(models.AbstractModel):
return res
def _write_move_lines_block(self, jdi, row, account, add2total=True):
# Returns row
# For suspense lines, it may not add any cells if there are no suspense lines
# => in this case, it doesn't increment row
# If it adds cells, it returns row + 2 to add 2 empty rows at the end
sheet = jdi['sheet']
style = jdi['style']
style_suffix = not add2total and '_warn' or ''
subtotal = 0.0
mlines = self._prepare_payment_move_lines(jdi['journal'], account, jdi['wizard'])
mlines = self._prepare_payment_move_lines(jdi, account)
if mlines or add2total:
sheet.write(row, 0, '%s %s' % (account.name, account.code), style['title' + style_suffix])
sheet.write(row, 1, "", style['title' + style_suffix])
sheet.write(row, 0, '%s %s' % (account.name, account.code), style[f"title{style_suffix}"])
sheet.write(row, 1, "", style[f"title{style_suffix}"])
if not mlines:
if add2total:
sheet.write(row, 2, _("None"), style['none'])
else:
return
return row
else:
row += 1
col_labels = [
_("Date"),
_("Partner"),
_("Amount"),
_("Move Number"),
_("Journal Entry"),
_("Counter-part"),
_("Ref."),
_("Label"),
@@ -108,7 +103,7 @@ class BankReconciliationXlsx(models.AbstractModel):
for mline in mlines:
sheet.write(row, 0, mline["date"], style['regular_date'])
sheet.write(row, 1, mline["partner"], style['regular'])
sheet.write(row, 2, mline["amount"], style['currency'])
sheet.write(row, 2, mline["amount"], style[jdi['currency']])
sheet.write(row, 3, mline["move_name"], style['regular'])
sheet.write(row, 4, mline["counterpart"], style['regular'])
sheet.write(row, 5, mline["ref"], style['regular'])
@@ -118,18 +113,20 @@ class BankReconciliationXlsx(models.AbstractModel):
end_line = row
for col in range(1):
sheet.write(row, col, "", style['title' + style_suffix])
sheet.write(row, 1, _("Sub-total:") + ' ', style['title_right' + style_suffix])
sheet.write(row, col, "", style[f"title{style_suffix}"])
sheet.write(row, 1, _("Sub-total:") + ' ', style[f"title_right{style_suffix}"])
formula = '=SUM(%s%d:%s%d)' % (
jdi['total_col'], start_line, jdi['total_col'], end_line)
sheet.write_formula(row, 2, formula, style['currency_bg' + style_suffix], subtotal)
formula = f"=SUM({jdi['total_col']}{start_line}:{jdi['total_col']}{end_line})"
sheet.write_formula(row, 2, formula, style[f"{jdi['currency']}_bg{style_suffix}"], subtotal)
if add2total:
jdi['total'] += subtotal
jdi['total_formula'] += '+%s%d' % (jdi['total_col'], row + 1)
return row
jdi['total_formula'] += f"+{jdi['total_col']}{row + 1}"
return row + 2
def generate_xlsx_report(self, workbook, data, wizard):
lang = self.env.user.lang
self = self.with_context(lang=lang)
wizard = wizard.with_context(lang=lang)
if not wizard.journal_ids:
raise UserError(_("No bank journal selected."))
date_dt = wizard.date
@@ -137,15 +134,21 @@ class BankReconciliationXlsx(models.AbstractModel):
style = self._get_style(workbook, company)
move_state_label = dict(
wizard.fields_get('move_state', 'selection')['move_state']['selection'])
generated_on_label = _('Generated on %s') % format_datetime(
self.env, datetime.utcnow())
generated_on_label = _('Generated from Odoo on %s by %s') % (
format_datetime(self.env, datetime.utcnow()),
self.env.user.name)
for journal in wizard.journal_ids:
row = 0
sheet = workbook.add_worksheet(journal.code or journal.name)
bank_account = journal.default_account_id
jdi = {
'wizard': wizard,
'company': company,
'journal': journal,
'currency': journal.currency_id or company.currency_id,
'bank_account': bank_account,
'style': style,
'workbook': workbook,
'sheet': sheet,
'total': 0.0,
'total_formula': '=',
@@ -169,7 +172,7 @@ class BankReconciliationXlsx(models.AbstractModel):
sheet.set_column(6, 6, 60)
row += 3
sheet.write(row, 0, _("Company"), style['wizard_field'])
sheet.write(row, 1, wizard.company_id.display_name, style['wizard_value'])
sheet.write(row, 1, company.display_name, style['wizard_value'])
row += 1
sheet.write(row, 0, _("Date"), style['wizard_field'])
sheet.write(row, 1, date_dt, style['wizard_value_date'])
@@ -177,51 +180,121 @@ class BankReconciliationXlsx(models.AbstractModel):
sheet.write(row, 0, _("Journal"), style['wizard_field'])
sheet.write(row, 1, journal.display_name, style['wizard_value'])
row += 1
sheet.write(row, 0, _("Currency"), style['wizard_field'])
sheet.write(row, 1, jdi['currency'].name, style['wizard_value'])
row += 1
sheet.write(row, 0, _("Entries"), style['wizard_field'])
sheet.write(row, 1, move_state_label[wizard.move_state], style['wizard_value'])
# Setup check
if journal.currency_id and journal.currency_id != company.currency_id:
if journal.currency_id != bank_account.currency_id:
raise UserError(_(
"On bank journal %(journal)s which is configured with currency "
"%(journal_currency)s, the account %(account)s must be configured "
"with the same currency (current account currency: %(account_currency)s).",
journal=journal.display_name,
journal_currency=journal.currency_id.name,
account=bank_account.display_name,
account_currency=bank_account.currency_id.name or _('None')))
bad_line_count = self.env['account.move.line'].search_count([
('company_id', '=', company.id),
('journal_id', '=', journal.id),
('account_id', '=', bank_account.id),
('currency_id', '!=', jdi['currency'].id),
])
if bad_line_count:
raise UserError(_(
"The are %(count)s journal items in account %(account)s "
"that have a currency other than %(currency)s or where "
"currency is not set.",
count=bad_line_count,
account=bank_account.display_name,
currency=jdi['currency'].name))
# 1) Show balance of bank account
row += 3
bank_account = journal.default_account_id
for col in range(1):
sheet.write(row, col, "", style['title'])
sheet.write(row, 1, _("Balance %s:") % bank_account.code + ' ', style['title_right'])
account_bal = self._get_account_balance(bank_account, wizard)
if wizard.move_state == 'posted':
domain = [('parent_state', '=', 'posted')]
else:
# by default, the native method _get_journal_bank_account_balance()
# has ('parent_state', '!=', 'cancel')
domain = None
account_bal, nb_lines = journal._get_journal_bank_account_balance(domain=domain)
sheet.write(row, 2, account_bal, style['currency_bg'])
sheet.write(row, 2, account_bal, style[f"{jdi['currency']}_bg"])
jdi['total'] += account_bal
jdi['total_formula'] += '%s%d' % (jdi['total_col'], row + 1)
jdi['total_formula'] += f"{jdi['total_col']}{row + 1}"
row += 2
# 2) Show payment lines IN (debit)
debit_account = journal.payment_debit_account_id
row = self._write_move_lines_block(jdi, row, debit_account)
row += 2
# 3) Show payment lines OUT (credit)
credit_account = journal.payment_credit_account_id
row = self._write_move_lines_block(jdi, row, credit_account)
row += 2
for col in range(1):
sheet.write(row, col, "", style['title'])
sheet.write(row, 1, _("TOTAL:") + ' ', style['title_right'])
sheet.write_formula(
row, 2, jdi['total_formula'], style['currency_bg'], jdi['total'])
row += 3
row, 2, jdi['total_formula'], style[f"{jdi['currency']}_bg"], jdi['total'])
total_row = row
row += 2
# 4) Show suspense account lines
row = self._write_move_lines_block(
jdi, row, journal.suspense_account_id, add2total=False)
# Static cells
for col in range(1):
sheet.write(row, col, "", style['title'])
sheet.write(row, 1, _("Bank Balance:") + ' ', style['title_right'])
sheet.write(row, 2, 0, style[f"{jdi['currency']}_bg_manual"])
bank_bal_row = row
row += 2
for col in range(1):
sheet.write(row, col, "", style['title'])
sheet.write(row, 1, _("Difference:") + ' ', style['title_right'])
sheet.write_formula(
row, 2, f"={jdi['total_col']}{total_row + 1}-{jdi['total_col']}{bank_bal_row + 1}",
style[f"{jdi['currency']}_bg"], jdi['total'])
row += 2
for col in range(1):
sheet.write(row, col, "", style['title'])
sheet.write(row, 1, _("Justification:") + ' ', style['title_right'])
justif_lines = 6
sheet.write_formula(
row, 2, f"=SUM({jdi['total_col']}{row+3}:{jdi['total_col']}{row+3+justif_lines-1})",
style[f"{jdi['currency']}_bg"], 0)
row += 1
col_labels = [
_("Date"),
_("Description"),
_("Amount"),
]
col = 0
for col_label in col_labels:
sheet.write(row, col, col_label, style['col_header'])
col += 1
for x in range(justif_lines):
row += 1
sheet.write(row, 0, "", style['regular_date'])
sheet.write(row, 1, "", style['regular'])
sheet.write(row, 2, "", style[jdi['currency']])
def _get_style(self, workbook, company):
style = {}
font_size = 10
light_grey = "#eeeeee"
title_blue = "#e6e6fa"
light_blue = "#e0edff"
subtotal_orange = "#ffcc00"
title_warn = "#ff9999"
subtotal_warn = "#ffff99"
light_purple = "#ffdeff"
amount_manual = "#ffeeab"
title_warn = "#ff9999"
lang_code = self.env.user.lang
lang = False
if lang_code:
@@ -249,7 +322,7 @@ class BankReconciliationXlsx(models.AbstractModel):
)
title_style = {
"bold": True,
"bg_color": title_blue,
"bg_color": light_blue,
"font_size": font_size,
"align": "left",
}
@@ -257,7 +330,7 @@ class BankReconciliationXlsx(models.AbstractModel):
style['title'] = workbook.add_format(dict(title_style))
style['wizard_field'] = workbook.add_format(dict(title_style, bg_color=light_grey))
wizard_value_style = {
"bg_color": light_purple,
"bg_color": light_blue,
"bold": True,
"font_size": font_size,
"align": "left",
@@ -274,23 +347,29 @@ class BankReconciliationXlsx(models.AbstractModel):
dict(title_style, align="left", bg_color=title_warn))
style['title_right_warn'] = workbook.add_format(
dict(title_style, align="right", bg_color=title_warn))
style['regular'] = workbook.add_format({"font_size": font_size})
style['regular'] = workbook.add_format({"font_size": font_size, "border": 1})
if "%" in xls_date_format:
# fallback
xls_date_format = "yyyy-mm-dd"
style['regular_date'] = workbook.add_format(
{"num_format": xls_date_format, "font_size": font_size, "align": "left"}
{"num_format": xls_date_format, "font_size": font_size, "align": "left", "border": 1}
)
cur_format = "#,##0.00 %s" % (
company.currency_id.symbol or company.currency_id.name
)
# It seems that Excel replaces automatically the decimal
# and thousand separator by those of the language under which
# Excel runs
currency_style = {"num_format": cur_format, "font_size": font_size}
style['currency'] = workbook.add_format(currency_style)
style['currency_bg'] = workbook.add_format(
dict(currency_style, bg_color=subtotal_orange))
style['currency_bg_warn'] = workbook.add_format(
dict(currency_style, bg_color=subtotal_warn))
for currency in self.env['res.currency'].search([]):
symbol = currency.symbol or currency.name
decimals = '0' * currency.decimal_places
if currency.position == 'before':
cur_format = f"{symbol} #,##0.{decimals}"
else:
cur_format = f"#,##0.{decimals} {symbol}"
# It seems that Excel replaces automatically the decimal
# and thousand separator by those of the language under which
# Excel runs
currency_style = {"num_format": cur_format, "font_size": font_size}
style[currency] = workbook.add_format(dict(currency_style, border=1))
style[f'{currency}_bg'] = workbook.add_format(
dict(currency_style, bg_color=subtotal_orange))
style[f'{currency}_bg_warn'] = workbook.add_format(
dict(currency_style, bg_color=subtotal_warn))
style[f'{currency}_bg_manual'] = workbook.add_format(
dict(currency_style, bg_color=amount_manual))
return style

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2017-2023 Akretion France (http://www.akretion.com/)
Copyright 2017-2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
@@ -12,7 +12,6 @@
<field name="report_type">xlsx</field>
<field name="report_name">bank.reconciliation.xlsx</field>
<field name="report_file">bank.reconciliation.xlsx</field>
<!-- print_report_name doesn't work here... -->
<field name="print_report_name">'bank_reconciliation-%s' % (object.date)</field>
</record>
</odoo>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2017-2020 Akretion France (http://www.akretion.com/)
Copyright 2017-2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2018-2023 Akretion France (http://www.akretion.com/)
Copyright 2018-2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
@@ -9,7 +9,7 @@
<record id="account_journal_dashboard_kanban_view" model="ir.ui.view">
<field
name="name"
>bank_reconciliation_summarry.account_journal_dashboard</field>
>bank_reconciliation_summary.account_journal_dashboard</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.account_journal_dashboard_kanban_view" />
<field name="arch" type="xml">

View File

@@ -1,4 +1,4 @@
# Copyright 2017-2023 Akretion France (http://www.akretion.com/)
# Copyright 2017-2024 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2017-2023 Akretion France (http://www.akretion.com/)
Copyright 2017-2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

View File

@@ -1,2 +1 @@
from . import account_invoice
from . import account_invoice_report
from . import models

View File

@@ -4,7 +4,7 @@
{
'name': 'Account Invoice Margin',
'version': '12.0.1.0.0',
'version': '14.0.1.0.0',
'category': 'Invoicing Management',
'license': 'AGPL-3',
'summary': 'Copy standard price on invoice line and compute margins',
@@ -15,10 +15,10 @@ This module has been written by Alexis de Lattre from Akretion
<alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'website': 'https://github.com/akretion/odoo-usability',
'depends': ['account'],
'data': [
'account_invoice_view.xml',
'views/account_move.xml',
],
'installable': False,
'installable': True,
}

View File

@@ -1,152 +0,0 @@
# Copyright 2015-2019 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
import odoo.addons.decimal_precision as dp
class AccountInvoiceLine(models.Model):
_inherit = 'account.invoice.line'
standard_price_company_currency = fields.Float(
string='Cost Price in Company Currency', readonly=True,
digits=dp.get_precision('Product Price'),
help="Cost price in company currency in the unit of measure "
"of the invoice line (which may be different from the unit "
"of measure of the product).")
standard_price_invoice_currency = fields.Float(
string='Cost Price in Invoice Currency', readonly=True,
compute='_compute_margin', store=True,
digits=dp.get_precision('Product Price'),
help="Cost price in invoice currency in the unit of measure "
"of the invoice line")
margin_invoice_currency = fields.Monetary(
string='Margin in Invoice Currency', readonly=True, store=True,
compute='_compute_margin', currency_field='currency_id')
margin_company_currency = fields.Monetary(
string='Margin in Company Currency', readonly=True, store=True,
compute='_compute_margin', currency_field='company_currency_id')
margin_rate = fields.Float(
string="Margin Rate", readonly=True, store=True,
compute='_compute_margin',
digits=(16, 2), help="Margin rate in percentage of the sale price")
@api.depends(
'standard_price_company_currency', 'invoice_id.currency_id',
'invoice_id.type', 'invoice_id.company_id',
'invoice_id.date_invoice', 'quantity', 'price_subtotal')
def _compute_margin(self):
for il in self:
standard_price_inv_cur = 0.0
margin_inv_cur = 0.0
margin_comp_cur = 0.0
margin_rate = 0.0
inv = il.invoice_id
if inv and inv.type in ('out_invoice', 'out_refund'):
# it works in _get_current_rate
# even if we set date = False in context
# standard_price_inv_cur is in the UoM of the invoice line
date = inv._get_currency_rate_date() or\
fields.Date.context_today(self)
company = inv.company_id
company_currency = company.currency_id
standard_price_inv_cur =\
company_currency._convert(
il.standard_price_company_currency,
inv.currency_id, company, date)
margin_inv_cur =\
il.price_subtotal - il.quantity * standard_price_inv_cur
margin_comp_cur = inv.currency_id._convert(
margin_inv_cur, company_currency, company, date)
if il.price_subtotal:
margin_rate = 100 * margin_inv_cur / il.price_subtotal
# for a refund, margin should be negative
# but margin rate should stay positive
if inv.type == 'out_refund':
margin_inv_cur *= -1
margin_comp_cur *= -1
il.standard_price_invoice_currency = standard_price_inv_cur
il.margin_invoice_currency = margin_inv_cur
il.margin_company_currency = margin_comp_cur
il.margin_rate = margin_rate
# We want to copy standard_price on invoice line for customer
# invoice/refunds. We can't do that via on_change of product_id,
# because it is not always played when invoice is created from code
# => we inherit write/create
# We write standard_price_company_currency even on supplier invoice/refunds
# because we don't have access to the 'type' of the invoice
@api.model
def create(self, vals):
if vals.get('product_id'):
pp = self.env['product.product'].browse(vals['product_id'])
std_price = pp.standard_price
inv_uom_id = vals.get('uom_id')
if inv_uom_id and inv_uom_id != pp.uom_id.id:
inv_uom = self.env['uom.uom'].browse(inv_uom_id)
std_price = pp.uom_id._compute_price(
std_price, inv_uom)
vals['standard_price_company_currency'] = std_price
return super(AccountInvoiceLine, self).create(vals)
def write(self, vals):
if not vals:
vals = {}
if 'product_id' in vals or 'uom_id' in vals:
for il in self:
if 'product_id' in vals:
if vals.get('product_id'):
pp = self.env['product.product'].browse(
vals['product_id'])
else:
pp = False
else:
pp = il.product_id or False
# uom_id is NOT a required field
if 'uom_id' in vals:
if vals.get('uom_id'):
inv_uom = self.env['uom.uom'].browse(
vals['uom_id'])
else:
inv_uom = False
else:
inv_uom = il.uom_id or False
std_price = 0.0
if pp:
std_price = pp.standard_price
if inv_uom and inv_uom != pp.uom_id:
std_price = pp.uom_id._compute_price(
std_price, inv_uom)
il.write({'standard_price_company_currency': std_price})
return super(AccountInvoiceLine, self).write(vals)
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
margin_invoice_currency = fields.Monetary(
string='Margin in Invoice Currency',
compute='_compute_margin', store=True, readonly=True,
currency_field='currency_id')
margin_company_currency = fields.Monetary(
string='Margin in Company Currency',
compute='_compute_margin', store=True, readonly=True,
currency_field='company_currency_id')
@api.depends(
'type',
'invoice_line_ids.margin_invoice_currency',
'invoice_line_ids.margin_company_currency')
def _compute_margin(self):
res = self.env['account.invoice.line'].read_group(
[('invoice_id', 'in', self.ids)],
['invoice_id', 'margin_invoice_currency',
'margin_company_currency'],
['invoice_id'])
for re in res:
if re['invoice_id']:
inv = self.browse(re['invoice_id'][0])
if inv.type in ('out_invoice', 'out_refund'):
inv.margin_invoice_currency = re['margin_invoice_currency']
inv.margin_company_currency = re['margin_company_currency']

View File

@@ -1,60 +0,0 @@
# Copyright 2018-2019 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class AccountInvoiceReport(models.Model):
_inherit = 'account.invoice.report'
margin = fields.Float(string='Margin', readonly=True)
# why digits=0 ??? Why is it like that in the native "account" module
user_currency_margin = fields.Float(
string="Margin", compute='_compute_user_currency_margin', digits=0)
_depends = {
'account.invoice': [
'account_id', 'amount_total_company_signed',
'commercial_partner_id', 'company_id',
'currency_id', 'date_due', 'date_invoice', 'fiscal_position_id',
'journal_id', 'number', 'partner_bank_id', 'partner_id',
'payment_term_id', 'residual', 'state', 'type', 'user_id',
],
'account.invoice.line': [
'account_id', 'invoice_id', 'price_subtotal', 'product_id',
'quantity', 'uom_id', 'account_analytic_id',
'margin_company_currency',
],
'product.product': ['product_tmpl_id'],
'product.template': ['categ_id'],
'uom.uom': ['category_id', 'factor', 'name', 'uom_type'],
'res.currency.rate': ['currency_id', 'name'],
'res.partner': ['country_id'],
}
@api.depends('currency_id', 'date', 'margin')
def _compute_user_currency_margin(self):
user_currency = self.env.user.company_id.currency_id
currency_rate = self.env['res.currency.rate'].search([
('rate', '=', 1),
'|',
('company_id', '=', self.env.user.company_id.id),
('company_id', '=', False)], limit=1)
base_currency = currency_rate.currency_id
for record in self:
date = record.date or fields.Date.today()
company = record.company_id
record.user_currency_margin = base_currency._convert(
record.margin, user_currency, company, date)
# TODO check for refunds
def _sub_select(self):
select_str = super(AccountInvoiceReport, self)._sub_select()
select_str += ", SUM(ail.margin_company_currency) AS margin"
return select_str
def _select(self):
select_str = super(AccountInvoiceReport, self)._select()
select_str += ", sub.margin AS margin"
return select_str

View File

@@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015-2017 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_invoice_line_form" model="ir.ui.view">
<field name="name">margin.account.invoice.line.form</field>
<field name="model">account.invoice.line</field>
<field name="inherit_id" ref="account.view_invoice_line_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='analytic_tag_ids']/.." position="inside">
<field name="standard_price_company_currency"
string="Cost Price in Comp. Cur."
groups="base.group_no_one"/>
<field name="standard_price_invoice_currency"
string="Cost Price in Inv. Cur."
groups="base.group_no_one"/>
<field name="margin_invoice_currency"
string="Margin in Inv. Cur."
groups="base.group_no_one"/>
<field name="margin_company_currency"
string="Margin in Comp. Cur."
groups="base.group_no_one"/>
<label for="margin_rate" groups="base.group_no_one"/>
<div name="margin_rate" groups="base.group_no_one">
<field name="margin_rate" class="oe_inline"/> %
</div>
</xpath>
</field>
</record>
<record id="invoice_form" model="ir.ui.view">
<field name="name">margin.account.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<field name="move_id" position="after">
<field name="margin_invoice_currency"
string="Margin in Inv. Cur." groups="base.group_no_one"/>
<field name="margin_company_currency"
string="Margin in Comp. Cur." groups="base.group_no_one"/>
</field>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,2 @@
from . import account_move
from . import account_invoice_report

View File

@@ -0,0 +1,36 @@
# Copyright 2018-2019 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class AccountInvoiceReport(models.Model):
_inherit = 'account.invoice.report'
margin = fields.Float(string='Margin', readonly=True)
# added margin_company_currency on account.move.line
_depends = {
'account.move': [
'name', 'state', 'move_type', 'partner_id', 'invoice_user_id', 'fiscal_position_id',
'invoice_date', 'invoice_date_due', 'invoice_payment_term_id', 'partner_bank_id',
],
'account.move.line': [
'quantity', 'price_subtotal', 'amount_residual', 'balance', 'amount_currency',
'move_id', 'product_id', 'product_uom_id', 'account_id', 'analytic_account_id',
'journal_id', 'company_id', 'currency_id', 'partner_id',
'margin_company_currency',
],
'product.product': ['product_tmpl_id'],
'product.template': ['categ_id'],
'uom.uom': ['category_id', 'factor', 'name', 'uom_type'],
'res.currency.rate': ['currency_id', 'name'],
'res.partner': ['country_id'],
}
@api.model
def _select(self):
select_str = super()._select()
select_str += ", line.margin_company_currency * currency_table.rate AS margin"
return select_str

View File

@@ -0,0 +1,155 @@
# Copyright 2015-2021 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
standard_price_company_currency = fields.Float(
string='Unit Cost Price in Company Currency', readonly=True,
digits='Product Price',
help="Unit Cost price in company currency in the unit of measure "
"of the invoice line (which may be different from the unit "
"of measure of the product).")
standard_price_invoice_currency = fields.Float(
string='Unit Cost Price in Invoice Currency',
compute='_compute_margin', store=True, digits='Product Price',
help="Unit Cost price in invoice currency in the unit of measure "
"of the invoice line.")
margin_invoice_currency = fields.Monetary(
string='Margin in Invoice Currency', store=True,
compute='_compute_margin', currency_field='currency_id')
margin_company_currency = fields.Monetary(
string='Margin in Company Currency', store=True,
compute='_compute_margin', currency_field='company_currency_id')
margin_rate = fields.Float(
string="Margin Rate", readonly=True, store=True,
compute='_compute_margin',
digits=(16, 2), help="Margin rate in percentage of the sale price")
@api.depends(
'standard_price_company_currency', 'move_id.currency_id',
'move_id.move_type', 'move_id.company_id',
'move_id.invoice_date', 'quantity', 'price_subtotal')
def _compute_margin(self):
for ml in self:
standard_price_inv_cur = 0.0
margin_inv_cur = 0.0
margin_comp_cur = 0.0
margin_rate = 0.0
move = ml.move_id
if move.move_type and move.move_type in ('out_invoice', 'out_refund'):
# it works in _get_current_rate
# even if we set date = False in context
# standard_price_inv_cur is in the UoM of the invoice line
date = move.date or fields.Date.context_today(self)
company = move.company_id
company_currency = company.currency_id
standard_price_inv_cur =\
company_currency._convert(
ml.standard_price_company_currency,
ml.currency_id, company, date)
margin_inv_cur =\
ml.price_subtotal - ml.quantity * standard_price_inv_cur
margin_comp_cur = move.currency_id._convert(
margin_inv_cur, company_currency, company, date)
if ml.price_subtotal:
margin_rate = 100 * margin_inv_cur / ml.price_subtotal
# for a refund, margin should be negative
# but margin rate should stay positive
if move.move_type == 'out_refund':
margin_inv_cur *= -1
margin_comp_cur *= -1
ml.standard_price_invoice_currency = standard_price_inv_cur
ml.margin_invoice_currency = margin_inv_cur
ml.margin_company_currency = margin_comp_cur
ml.margin_rate = margin_rate
# We want to copy standard_price on invoice line for customer
# invoice/refunds. We can't do that via on_change of product_id,
# because it is not always played when invoice is created from code
# => we inherit write/create
# We write standard_price_company_currency even on supplier invoice/refunds
# because we don't have access to the 'type' of the invoice
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get('product_id') and not vals.get('display_type'):
pp = self.env['product.product'].browse(vals['product_id'])
std_price = pp.standard_price
inv_uom_id = vals.get('product_uom_id')
if inv_uom_id and inv_uom_id != pp.uom_id.id:
inv_uom = self.env['uom.uom'].browse(inv_uom_id)
std_price = pp.uom_id._compute_price(
std_price, inv_uom)
vals['standard_price_company_currency'] = std_price
return super().create(vals_list)
def write(self, vals):
if not vals:
vals = {}
if 'product_id' in vals or 'product_uom_id' in vals:
for il in self:
if 'product_id' in vals:
if vals.get('product_id'):
pp = self.env['product.product'].browse(
vals['product_id'])
else:
pp = False
else:
pp = il.product_id or False
# uom_id is NOT a required field
if 'product_uom_id' in vals:
if vals.get('product_uom_id'):
inv_uom = self.env['uom.uom'].browse(
vals['product_uom_id'])
else:
inv_uom = False
else:
inv_uom = il.uom_id or False
std_price = 0.0
if pp:
std_price = pp.standard_price
if inv_uom and inv_uom != pp.uom_id:
std_price = pp.uom_id._compute_price(
std_price, inv_uom)
il.write({'standard_price_company_currency': std_price})
return super().write(vals)
class AccountMove(models.Model):
_inherit = 'account.move'
margin_invoice_currency = fields.Monetary(
string='Margin in Invoice Currency',
compute='_compute_margin', store=True,
currency_field='currency_id')
margin_company_currency = fields.Monetary(
string='Margin in Company Currency',
compute='_compute_margin', store=True,
currency_field='company_currency_id')
@api.depends(
'move_type',
'invoice_line_ids.margin_invoice_currency',
'invoice_line_ids.margin_company_currency')
def _compute_margin(self):
rg_res = self.env['account.move.line'].read_group(
[
('move_id', 'in', self.ids),
('display_type', '=', False),
('exclude_from_invoice_tab', '=', False),
('move_id.move_type', 'in', ('out_invoice', 'out_refund')),
],
['move_id', 'margin_invoice_currency:sum', 'margin_company_currency:sum'],
['move_id'])
mapped_data = dict([(x['move_id'][0], {
'margin_invoice_currency': x['margin_invoice_currency'],
'margin_company_currency': x['margin_company_currency'],
}) for x in rg_res])
for move in self:
move.margin_invoice_currency = mapped_data.get(move.id, {}).get('margin_invoice_currency')
move.margin_company_currency = mapped_data.get(move.id, {}).get('margin_company_currency')

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2015-2024 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_move_form" model="ir.ui.view">
<field name="name">margin.account.move.form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<group name="sale_info_group" position="inside">
<field name="margin_invoice_currency"
groups="base.group_no_one"
attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund'))]}"/>
<field name="margin_company_currency"
groups="base.group_no_one"
attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund'))]}"/>
</group>
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='price_total']" position="after">
<field name="standard_price_invoice_currency" optional="hide" attrs="{'column_invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}"/>
<field name="margin_invoice_currency" optional="hide" attrs="{'column_invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}"/>
<field name="margin_rate" optional="hide" string="Margin Rate (%)" attrs="{'column_invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}"/>
</xpath>
<xpath expr="//field[@name='invoice_line_ids']/form//field[@name='price_total']/.." position="inside">
<field name="standard_price_company_currency"
groups="base.group_no_one" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}"/>
<field name="standard_price_invoice_currency"
groups="base.group_no_one" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}"/>
<field name="margin_invoice_currency"
groups="base.group_no_one" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}"/>
<field name="margin_company_currency"
groups="base.group_no_one" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}"/>
<label for="margin_rate" groups="base.group_no_one" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}"/>
<div name="margin_rate" groups="base.group_no_one" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}">
<field name="margin_rate" class="oe_inline"/> %
</div>
</xpath>
</field>
</record>
<record id="view_invoice_tree" model="ir.ui.view">
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_invoice_tree"/>
<field name="arch" type="xml">
<field name="amount_residual_signed" position="after">
<field name="margin_company_currency" optional="hide" sum="1" invisible="context.get('default_move_type') not in ('out_invoice', 'out_refund')" string="Margin"/>
</field>
</field>
</record>
</odoo>

View File

@@ -11,7 +11,8 @@
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<button name="button_draft" position="before">
<button name="prepare_update_wizard" type="object" string="Update Invoice" states="posted" groups="account.group_account_invoice"/>
<button name="prepare_update_wizard" type="object" string="Update Invoice" groups="account.group_account_invoice" attrs="{'invisible': ['|', ('state', '!=', 'posted'), ('move_type', '=', 'entry')]}"/>
<button name="prepare_update_wizard" type="object" string="Update Entry" groups="account.group_account_invoice" attrs="{'invisible': ['|', ('state', '!=', 'posted'), ('move_type', '!=', 'entry')]}"/>
</button>
</field>
</record>

View File

@@ -21,6 +21,7 @@ class AccountMoveUpdate(models.TransientModel):
invoice_payment_term_id = fields.Many2one(
'account.payment.term', string='Payment Term')
ref = fields.Char(string='Reference') # field label is customized in the view
invoice_date = fields.Date()
invoice_origin = fields.Char(string='Source Document')
partner_bank_id = fields.Many2one(
'res.partner.bank', string='Bank Account')
@@ -30,7 +31,7 @@ class AccountMoveUpdate(models.TransientModel):
@api.model
def _simple_fields2update(self):
'''List boolean, date, datetime, char, text fields'''
return ['ref', 'invoice_origin']
return ['ref', 'invoice_origin', 'invoice_date']
@api.model
def _m2o_fields2update(self):
@@ -226,6 +227,12 @@ class AccountMoveUpdate(models.TransientModel):
inv.message_post(body=_(
'Non-legal fields of invoice updated via the Invoice Update '
'wizard.'))
# Purge existing PDF
report = self.env.ref("account.account_invoices")
attachment = report.retrieve_attachment(inv)
# attachment may be None
if attachment:
attachment.unlink()
return True

View File

@@ -15,13 +15,15 @@
<field name="move_type" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="partner_id" invisible="1"/>
<field string="Bill Reference" attrs="{'invisible': [('move_type', 'not in', ('in_invoice', 'in_refund'))]}" name="ref"/>
<field string="Bill Date" attrs="{'invisible': [('move_type', 'not in', ('in_invoice', 'in_refund'))]}" name="invoice_date"/>
<field string="Supplier Bill Reference" attrs="{'invisible': [('move_type', 'not in', ('in_invoice', 'in_refund'))]}" name="ref"/>
<field string="Customer Reference" attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund'))]}" name="ref"/>
<field name="invoice_origin"/>
<field string="Ref" attrs="{'invisible': [('move_type', '!=', 'entry')]}" name="ref"/>
<field name="invoice_origin" attrs="{'invisible': [('move_type', '=', 'entry')]}"/>
<!-- update of payment term is broken -->
<!-- <field name="invoice_payment_term_id" widget="selection"/>-->
<field name="partner_bank_id"/>
<field name="user_id" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
<field name="partner_bank_id" attrs="{'invisible': [('move_type', '=', 'entry')]}"/>
<field name="user_id" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}" attrs="{'invisible': [('move_type', '=', 'entry')]}"/>
</group>
<group name="lines">
<field name="line_ids" nolabel="1" widget="section_and_note_one2many">
@@ -30,8 +32,8 @@
<field name="display_type" invisible="1"/>
<field name="currency_id" invisible="1"/>
<field name="name"/>
<field name="quantity" attrs="{'invisible': [('display_type', '!=', False)]}"/>
<field name="price_subtotal" attrs="{'invisible': [('display_type', '!=', False)]}"/>
<field name="quantity" attrs="{'invisible': [('display_type', '!=', False)], 'column_invisible': [('parent.move_type', '=', 'entry')]}"/>
<field name="price_subtotal" attrs="{'invisible': [('display_type', '!=', False)], 'column_invisible': [('parent.move_type', '=', 'entry')]}"/>
<field name="analytic_account_id" attrs="{'invisible': [('display_type', '!=', False)]}" groups="analytic.group_analytic_accounting"/>
<field name="analytic_tag_ids" attrs="{'invisible': [('display_type', '!=', False)]}" groups="analytic.group_analytic_tags" widget="many2many_tags"/>
</tree>

View File

@@ -1,2 +1 @@
from . import models
from . import wizard

View File

@@ -0,0 +1,25 @@
# Copyright 2024 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Account Payment Line Manual Account',
'version': '14.0.1.0.0',
'category': 'Accounting',
'license': 'AGPL-3',
'summary': 'Ability to select the account on payment lines without journal item',
'description': """
With this module, when you manually create a payment line that is not linked to a journal item, you can select an account (by default, it is set to the payable/receivable account of the partner) : this account will be used as the counter part of the outbound/inbound payment account configured on the bank journal. It covers special needs of a few companies that use SEPA credit transfer for the same partner in different accounting scenarios.
This module has been written by Alexis de Lattre from Akretion
<alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'maintainers': ['alexis-via'],
'website': 'https://github.com/akretion/odoo-usability',
'depends': ['account_payment_order'],
'data': [
"views/account_payment_line.xml",
],
'installable': True,
}

View File

@@ -0,0 +1,2 @@
from . import account_payment_line
from . import account_payment_order

View File

@@ -0,0 +1,38 @@
# Copyright 2024 Akretion France (https://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class AccountPaymentLine(models.Model):
_inherit = "account.payment.line"
account_id = fields.Many2one(
'account.account',
compute="_compute_account_id", store=True, readonly=False, check_company=True,
domain="[('company_id', '=', company_id), ('deprecated', '=', False)]")
analytic_account_id = fields.Many2one(
'account.analytic.account', string='Analytic Account',
domain="[('company_id', 'in', [False, company_id])]",
check_company=True)
@api.depends('move_line_id', 'partner_id')
def _compute_account_id(self):
for line in self:
account_id = False
if not line.move_line_id and line.partner_id:
partner = line.partner_id.with_company(line.order_id.company_id.id)
if line.order_id.payment_type == "inbound":
account_id = partner.property_account_receivable_id.id
else:
account_id = partner.property_account_payable_id.id
line.account_id = account_id
# take info account account_id for grouping
def payment_line_hashcode(self):
hashcode = super().payment_line_hashcode()
account_str = str(self.account_id.id or False)
analytic_account_str = str(self.analytic_account_id.id or False)
hashcode = '-'.join([hashcode, account_str, analytic_account_str])
return hashcode

View File

@@ -0,0 +1,18 @@
# Copyright 2024 Akretion France (https://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models
class AccountPaymentOrder(models.Model):
_inherit = "account.payment.order"
def _prepare_move_line_partner_account(self, bank_line):
vals = super()._prepare_move_line_partner_account(bank_line)
if not bank_line.payment_line_ids[0].move_line_id:
vals.update({
'account_id': bank_line.payment_line_ids[0].account_id.id,
'analytic_account_id': bank_line.payment_line_ids[0].analytic_account_id.id or False,
})
return vals

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Akretion France (https://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="account_payment_line_form" model="ir.ui.view">
<field name="model">account.payment.line</field>
<field name="inherit_id" ref="account_payment_order.account_payment_line_form"/>
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="account_id" attrs="{'invisible': [('move_line_id', '!=', False)], 'required': [('move_line_id', '=', False)]}"/>
<field name="analytic_account_id" attrs="{'invisible': [('move_line_id', '!=', False)]}" groups="analytic.group_analytic_accounting"/>
</field>
</field>
</record>
<record id="account_payment_line_tree" model="ir.ui.view">
<field name="model">account.payment.line</field>
<field name="inherit_id" ref="account_payment_order.account_payment_line_tree"/>
<field name="arch" type="xml">
<field name="move_line_id" position="after">
<field name="account_id" optional="hide"/>
<field name="analytic_account_id" optional="hide" groups="analytic.group_analytic_accounting"/>
</field>
</field>
</record>
</odoo>

View File

@@ -30,6 +30,7 @@
'views/product.xml',
'views/res_config_settings.xml',
'views/res_company.xml',
'views/res_partner.xml',
'views/account_report.xml',
'views/account_reconcile_model.xml',
'wizard/account_invoice_mark_sent_view.xml',

View File

@@ -43,13 +43,6 @@ class AccountBankStatement(models.Model):
res.append((statement.id, name))
return res
def button_reopen(self):
self = self.with_context(skip_undo_reconciliation=True)
return super().button_reopen()
def button_undo_reconciliation(self):
self.line_ids.button_undo_reconciliation()
class AccountBankStatementLine(models.Model):
_inherit = 'account.bank.statement.line'
@@ -96,9 +89,3 @@ class AccountBankStatementLine(models.Model):
'res_id': self.move_id.id,
})
return action
def button_undo_reconciliation(self):
if self._context.get("skip_undo_reconciliation"):
return
else:
return super().button_undo_reconciliation()

View File

@@ -10,6 +10,8 @@ from odoo.exceptions import UserError, ValidationError
from odoo.osv import expression
from odoo.tools import float_is_zero
from odoo.tools.misc import format_date
from odoo.tools.safe_eval import safe_eval, time
from collections import defaultdict
_logger = logging.getLogger(__name__)
@@ -50,6 +52,39 @@ class AccountMove(models.Model):
string="Dispute",
tracking=True,
)
# Having amounts in invoice currency can be useful in tree view of invoices
# We add those fields with optional="hide"
amount_untaxed_invoice_currency_signed = fields.Monetary(
compute="_compute_amount_invoice_currency_signed", store=True,
string="Untaxed Amount Invoice Currency Signed")
amount_tax_invoice_currency_signed = fields.Monetary(
compute="_compute_amount_invoice_currency_signed", store=True,
string="Tax Invoice Currency Signed")
amount_total_invoice_currency_signed = fields.Monetary(
compute="_compute_amount_invoice_currency_signed", store=True,
string="Total Invoice Currency Signed")
amount_residual_invoice_currency_signed = fields.Monetary(
compute="_compute_amount_invoice_currency_signed", store=True,
string="Amount Due Invoice Currency Signed")
# Field search_account_id is just for search view
search_account_id = fields.Many2one(related='line_ids.account_id')
@api.depends('amount_untaxed', 'amount_tax', 'amount_total', 'amount_residual', 'move_type')
def _compute_amount_invoice_currency_signed(self):
for move in self:
amount_untaxed_invoice_currency_signed = move.amount_untaxed
amount_tax_invoice_currency_signed = move.amount_tax
amount_total_invoice_currency_signed = move.amount_total
amount_residual_invoice_currency_signed = move.amount_residual
if move.move_type in ('out_refund', 'in_refund'):
amount_untaxed_invoice_currency_signed *= -1
amount_tax_invoice_currency_signed *= -1
amount_total_invoice_currency_signed *= -1
amount_residual_invoice_currency_signed *= -1
move.amount_untaxed_invoice_currency_signed = amount_untaxed_invoice_currency_signed
move.amount_tax_invoice_currency_signed = amount_tax_invoice_currency_signed
move.amount_total_invoice_currency_signed = amount_total_invoice_currency_signed
move.amount_residual_invoice_currency_signed = amount_residual_invoice_currency_signed
@api.depends("line_ids", "line_ids.blocked")
def _compute_blocked(self):
@@ -223,33 +258,14 @@ class AccountMove(models.Model):
move.suitable_journal_ids = self.env['account.journal'].search(domain)
def button_draft(self):
super().button_draft()
# Delete attached pdf invoice
try:
report_invoice = self.env['ir.actions.report']._get_report_from_name('account.report_invoice')
except IndexError:
report_invoice = False
if report_invoice and report_invoice.attachment:
for move in self.filtered(lambda x: x.move_type in ('out_invoice', 'out_refund')):
# The pb is that the filename is dynamic and related to move.state
# in v12, the feature was native and they used that kind of code:
# with invoice.env.do_in_draft():
# invoice.number, invoice.state = invoice.move_name, 'open'
# attachment = self.env.ref('account.account_invoices').retrieve_attachment(invoice)
# But do_in_draft() doesn't exists in v14
# If you know how we could do that, please update the code below
attachment = self.env['ir.attachment'].search([
('name', '=', self._get_invoice_attachment_name()),
('res_id', '=', move.id),
('res_model', '=', self._name),
('type', '=', 'binary'),
], limit=1)
if attachment:
attachment.unlink()
def _get_invoice_attachment_name(self):
self.ensure_one()
return '%s.pdf' % (self.name and self.name.replace('/', '_') or 'INV')
for move in self.filtered(lambda x: x.move_type in ('out_invoice', 'out_refund')):
for report_xmlid in ('account.account_invoices', 'account.account_invoices_without_payment'):
report = self.env.ref(report_xmlid)
attach = report.retrieve_attachment(move)
if attach:
attach.unlink()
super().button_draft()
def _get_accounting_date(self, invoice_date, has_tax):
# On vendor bills/refunds, we want date = invoice_date unless

View File

@@ -16,14 +16,6 @@
<button name="button_reopen" position="attributes">
<attribute name="confirm">Are you sure ? Don't do 'Reset to New' if you just want to modify the bank journal entry of an existing statement line.</attribute>
</button>
<button name="button_reopen" position="after">
<button
name="button_undo_reconciliation"
type="object"
confirm="Are you sure to unreconcile all the entries of the bank statement?"
states="open"
string="Unreconcile All"/>
</button>
<xpath expr="//field[@name='line_ids']/tree/button[@name='button_undo_reconciliation']" position="after">
<field name="move_id" invisible="1"/>
<button name="show_account_move" type="object"

View File

@@ -67,6 +67,14 @@
<field name="amount_residual_signed" position="attributes">
<attribute name="optional">show</attribute>
</field>
<field name="amount_untaxed_signed" position="before">
<!-- No sum="1" on the invoice currency fields, because it doesn't make sense
to add amounts in different currencies -->
<field name="amount_untaxed_invoice_currency_signed" string="Tax Excluded Inv. Cur." optional="hide"/>
<field name="amount_tax_invoice_currency_signed" string="Tax Inv. Cur." optional="hide"/>
<field name="amount_total_invoice_currency_signed" string="Total Inv. Cur." optional="hide"/>
<field name="amount_residual_invoice_currency_signed" string="Amount Due Inv. Cur." optional="hide"/>
</field>
</field>
</record>
@@ -93,6 +101,16 @@
</field>
</record>
<record id="view_account_move_filter" model="ir.ui.view">
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_account_move_filter"/>
<field name="arch" type="xml">
<field name="journal_id" position="after">
<field name="search_account_id"/>
</field>
</field>
</record>
<record id="view_move_line_form" model="ir.ui.view">
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_form"/>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_partner_property_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='bank_ids']/tree/field[@name='acc_holder_name']" position="attributes">
<attribute name="invisible">0</attribute>
<attribute name="optional">hide</attribute>
</xpath>
</field>
</record>
</odoo>

View File

@@ -21,10 +21,12 @@ class AccountMoveReversal(models.TransientModel):
moves = amo.browse(self._context['active_ids'])
if len(moves) == 1 and moves.move_type not in ('out_invoice', 'in_invoice'):
res['date'] = moves.date + relativedelta(days=1)
reversed_move = amo.search([('reversed_entry_id', 'in', moves.ids)], limit=1)
if reversed_move:
raise UserError(_(
"Move '%s' has already been reversed by move '%s'.") % (
reversed_move.reversed_entry_id.display_name,
reversed_move.display_name))
entry_moves = moves.filtered(lambda m: m.move_type == "entry")
if entry_moves:
reversed_move = amo.search([('reversed_entry_id', 'in', entry_moves.ids)], limit=1)
if reversed_move:
raise UserError(_(
"Move '%s' has already been reversed by move '%s'.") % (
reversed_move.reversed_entry_id.display_name,
reversed_move.display_name))
return res

View File

@@ -0,0 +1,13 @@
diff --git a/odoo/tools/mimetypes.py b/odoo/tools/mimetypes.py
index d104198a4ae..6eeabcc63a3 100644
--- a/odoo/tools/mimetypes.py
+++ b/odoo/tools/mimetypes.py
@@ -123,7 +123,7 @@ _mime_mappings = (
_Entry('image/png', [b'\x89PNG\r\n\x1A\n'], []),
_Entry('image/gif', [b'GIF87a', b'GIF89a'], []),
_Entry('image/bmp', [b'BM'], []),
- _Entry('image/svg+xml', [b'<'], [
+ _Entry('application/xml', [b'<'], [
_check_svg,
]),
_Entry('image/x-icon', [b'\x00\x00\x01\x00'], []),

View File

@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-07-01 10:02+0000\n"
"PO-Revision-Date: 2021-07-01 10:02+0000\n"
"POT-Creation-Date: 2024-03-26 21:27+0000\n"
"PO-Revision-Date: 2024-03-26 21:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -15,6 +15,18 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
#, python-format
msgid "%s with a capital of"
msgstr ""
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
#, python-format
msgid "APE:"
msgstr ""
#. module: base_usability
#: model:ir.model,name:base_usability.model_res_partner_bank
msgid "Bank Accounts"
@@ -25,11 +37,22 @@ msgstr ""
msgid "Bank Name"
msgstr ""
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
#, python-format
msgid "Capital:"
msgstr ""
#. module: base_usability
#: model:ir.model,name:base_usability.model_res_company
msgid "Companies"
msgstr ""
#. module: base_usability
#: model_terms:ir.ui.view,arch_db:base_usability.ir_property_view_search
msgid "Company"
msgstr ""
#. module: base_usability
#: model:ir.model,name:base_usability.model_res_partner
msgid "Contact"
@@ -48,6 +71,7 @@ msgid "Customer Number:"
msgstr ""
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_ir_actions_report__display_name
#: model:ir.model.fields,field_description:base_usability.field_ir_mail_server__display_name
#: model:ir.model.fields,field_description:base_usability.field_ir_model__display_name
#: model:ir.model.fields,field_description:base_usability.field_res_company__display_name
@@ -65,12 +89,24 @@ msgstr ""
msgid "E-mail:"
msgstr ""
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
#, python-format
msgid "EORI:"
msgstr ""
#. module: base_usability
#: model_terms:ir.ui.view,arch_db:base_usability.ir_property_view_search
msgid "Field"
msgstr ""
#. module: base_usability
#: model_terms:ir.ui.view,arch_db:base_usability.res_country_search
msgid "Group By"
msgstr ""
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_ir_actions_report__id
#: model:ir.model.fields,field_description:base_usability.field_ir_mail_server__id
#: model:ir.model.fields,field_description:base_usability.field_ir_model__id
#: model:ir.model.fields,field_description:base_usability.field_res_company__id
@@ -87,6 +123,7 @@ msgid "Installable"
msgstr ""
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_ir_actions_report____last_update
#: model:ir.model.fields,field_description:base_usability.field_ir_mail_server____last_update
#: model:ir.model.fields,field_description:base_usability.field_ir_model____last_update
#: model:ir.model.fields,field_description:base_usability.field_res_company____last_update
@@ -139,6 +176,11 @@ msgstr ""
msgid "Partner Tags"
msgstr ""
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_ir_actions_report__print_report_name
msgid "Printed Report Name"
msgstr ""
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_res_partner__ref
#: model:ir.model.fields,field_description:base_usability.field_res_users__ref
@@ -146,8 +188,14 @@ msgid "Reference"
msgstr ""
#. module: base_usability
#: model_terms:ir.ui.view,arch_db:base_usability.res_country_search
msgid "Search Countries"
#: model:ir.model,name:base_usability.model_ir_actions_report
msgid "Report Action"
msgstr ""
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
#, python-format
msgid "SIRET:"
msgstr ""
#. module: base_usability
@@ -169,6 +217,14 @@ msgstr ""
msgid "Tel:"
msgstr ""
#. module: base_usability
#: model:ir.model.fields,help:base_usability.field_ir_actions_report__print_report_name
msgid ""
"This is the filename of the report going to download. Keep empty to not "
"change the report filename. You can use a python expression with the "
"'object' and 'time' variables."
msgstr ""
#. module: base_usability
#: model:ir.model,name:base_usability.model_res_users
msgid "Users"

View File

@@ -6,15 +6,27 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-07-01 10:02+0000\n"
"PO-Revision-Date: 2021-07-01 12:15+0200\n"
"Last-Translator: Alexis de Lattre <alexis@via.ecp.fr>\n"
"POT-Creation-Date: 2024-03-26 21:27+0000\n"
"PO-Revision-Date: 2024-03-26 21:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
#, python-format
msgid "%s with a capital of"
msgstr "%s au capital de"
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
#, python-format
msgid "APE:"
msgstr "APE :"
#. module: base_usability
#: model:ir.model,name:base_usability.model_res_partner_bank
msgid "Bank Accounts"
@@ -25,11 +37,22 @@ msgstr "Comptes bancaires"
msgid "Bank Name"
msgstr "Nom de la banque"
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
#, python-format
msgid "Capital:"
msgstr "Capital : "
#. module: base_usability
#: model:ir.model,name:base_usability.model_res_company
msgid "Companies"
msgstr "Sociétés"
#. module: base_usability
#: model_terms:ir.ui.view,arch_db:base_usability.ir_property_view_search
msgid "Company"
msgstr "Société"
#. module: base_usability
#: model:ir.model,name:base_usability.model_res_partner
msgid "Contact"
@@ -42,11 +65,13 @@ msgstr "Devise"
#. module: base_usability
#: code:addons/base_usability/models/res_partner.py:0
#: code:addons/base_usability/models/res_partner.py:0
#, python-format
msgid "Customer Number:"
msgstr "N° client :"
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_ir_actions_report__display_name
#: model:ir.model.fields,field_description:base_usability.field_ir_mail_server__display_name
#: model:ir.model.fields,field_description:base_usability.field_ir_model__display_name
#: model:ir.model.fields,field_description:base_usability.field_res_company__display_name
@@ -64,12 +89,24 @@ msgstr "Nom affiché"
msgid "E-mail:"
msgstr "E-mail :"
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
#, python-format
msgid "EORI:"
msgstr "EORI :"
#. module: base_usability
#: model_terms:ir.ui.view,arch_db:base_usability.ir_property_view_search
msgid "Field"
msgstr "Champ"
#. module: base_usability
#: model_terms:ir.ui.view,arch_db:base_usability.res_country_search
msgid "Group By"
msgstr "Grouper par"
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_ir_actions_report__id
#: model:ir.model.fields,field_description:base_usability.field_ir_mail_server__id
#: model:ir.model.fields,field_description:base_usability.field_ir_model__id
#: model:ir.model.fields,field_description:base_usability.field_res_company__id
@@ -78,7 +115,7 @@ msgstr "Grouper par"
#: model:ir.model.fields,field_description:base_usability.field_res_partner_category__id
#: model:ir.model.fields,field_description:base_usability.field_res_users__id
msgid "ID"
msgstr "ID"
msgstr ""
#. module: base_usability
#: model_terms:ir.ui.view,arch_db:base_usability.view_module_filter
@@ -86,6 +123,7 @@ msgid "Installable"
msgstr "Installable"
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_ir_actions_report____last_update
#: model:ir.model.fields,field_description:base_usability.field_ir_mail_server____last_update
#: model:ir.model.fields,field_description:base_usability.field_ir_model____last_update
#: model:ir.model.fields,field_description:base_usability.field_res_company____last_update
@@ -136,7 +174,12 @@ msgstr "Personne (utilisé pour cacher des entrées de menu natifs)"
#. module: base_usability
#: model:ir.model,name:base_usability.model_res_partner_category
msgid "Partner Tags"
msgstr "Étiquettes du partenaire"
msgstr "Étiquettes contact"
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_ir_actions_report__print_report_name
msgid "Printed Report Name"
msgstr "Nom du rapport imprimé"
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_res_partner__ref
@@ -145,11 +188,18 @@ msgid "Reference"
msgstr "Référence"
#. module: base_usability
#: model_terms:ir.ui.view,arch_db:base_usability.res_country_search
msgid "Search Countries"
#: model:ir.model,name:base_usability.model_ir_actions_report
msgid "Report Action"
msgstr ""
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
#, python-format
msgid "SIRET:"
msgstr "SIRET :"
#. module: base_usability
#: code:addons/base_usability/models/res_partner.py:0
#: code:addons/base_usability/models/res_partner.py:0
#, python-format
msgid "Supplier Number:"
@@ -158,7 +208,7 @@ msgstr "N° fournisseur :"
#. module: base_usability
#: model:ir.model.fields,field_description:base_usability.field_res_partner_category__name
msgid "Tag Name"
msgstr "Nom de l'étiquette"
msgstr "Libellé de l'étiquette"
#. module: base_usability
#: code:addons/base_usability/models/res_company.py:0
@@ -167,6 +217,14 @@ msgstr "Nom de l'étiquette"
msgid "Tel:"
msgstr "Tél :"
#. module: base_usability
#: model:ir.model.fields,help:base_usability.field_ir_actions_report__print_report_name
msgid ""
"This is the filename of the report going to download. Keep empty to not "
"change the report filename. You can use a python expression with the "
"'object' and 'time' variables."
msgstr ""
#. module: base_usability
#: model:ir.model,name:base_usability.model_res_users
msgid "Users"

View File

@@ -3,6 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models, _
from odoo.tools.misc import format_amount
class ResCompany(models.Model):
@@ -39,32 +40,82 @@ class ResCompany(models.Model):
'value': self.phone,
# http://www.fileformat.info/info/unicode/char/1f4de/index.htm
'icon': '\U0001F4DE',
'label': _('Tel:')},
'label': _('Tel:'),
},
'email': {
'value': self.email,
# http://www.fileformat.info/info/unicode/char/2709/index.htm
'icon': '\u2709',
'label': _('E-mail:')},
'label': _('E-mail:'),
},
'website': {
'value': self.website,
'icon': '\U0001f310',
'label': _('Website:')},
'label': _('Website:'),
},
'vat': {
'value': self.vat,
'label': _('VAT:')},
'label': _('VAT:'),
},
'ape': {
'value': hasattr(self, 'ape') and self.ape or False,
'label': _('APE:'),
},
'siret': {
'value': hasattr(self, 'siret') and self.siret or False,
'label': _('SIRET:'),
},
'siren': {
'value': hasattr(self, 'siren') and self.siren or False,
'label': _('SIREN:'),
},
'rcs_siren': {
'value': hasattr(self, 'siren') and self.siren and self.company_registry and f"{self.company_registry} {self.siren}",
'label': 'RCS',
},
'eori': {
'value': self._get_eori(),
'label': _('EORI:'),
},
'capital': {
# 'capital_amount' added by base_company_extension
'value': hasattr(self, 'capital_amount') and self.capital_amount and format_amount(self.env, self.capital_amount, self.currency_id) or False,
'label': _('Capital:'),
}
}
# 'legal_type' added by base_company_extension
if hasattr(self, 'legal_type') and self.legal_type:
options['capital']['label'] = _('%s with a capital of') % self.legal_type
return options
def _get_eori(self):
eori = False
if self.partner_id.country_id.code == 'FR' and hasattr(self, 'siret') and self.siret:
# Currently migrating from EORI-SIRET to EORI-SIREN :
# https://www.pwcavocats.com/fr/ealertes/ealertes-france/2023/avril/reforme-numero-eori-siren-siret.html
# But, for the moment, we continue to use EORI-SIRET
eori = f'FR{self.siret}'
return eori
def _report_company_legal_name(self):
'''Method inherited in the module base_company_extension'''
self.ensure_one()
return self.name
def _report_header_line_details(self):
"""This method is designed to be inherited"""
# I decided not to put email in the default header because only a few very small
# companies have a generic company email address
line_details = [['phone', 'website', 'rcs_siren', 'capital'], ['vat', 'siret', 'eori', 'ape']]
return line_details
# for reports
def _display_report_header(
self, line_details=[['phone', 'website'], ['vat']],
icon=True, line_separator=' - '):
self, line_details=None, icon=True, line_separator=' - '):
self.ensure_one()
if line_details is None:
line_details = self._report_header_line_details()
res = ''
address = self.partner_id._display_address(without_company=True)
address = address.replace('\n', ' - ')

View File

@@ -125,6 +125,20 @@ class ResPartner(models.Model):
'label': _('Supplier Number:'),
},
}
if hasattr(self, 'siren'):
options['siren'] = {
'value': self.siren,
'label': _("SIREN:"),
}
if hasattr(self, 'siret'):
if hasattr(self, 'siren'): # l10n_fr_siret is installed
siret = self.siren and self.nic and self.siret or False
else:
siret = self.siret
options['siret'] = {
'value': siret,
'label': _("SIRET:"),
}
res = []
for detail in details:
if options.get(detail) and options[detail]['value']:

View File

@@ -27,6 +27,17 @@
</field>
</record>
<record id="res_partner_view_form_private" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.res_partner_view_form_private"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='bank_ids']/tree/field[@name='acc_holder_name']" position="attributes">
<attribute name="invisible">0</attribute>
<attribute name="optional">hide</attribute>
</xpath>
</field>
</record>
<record id="view_partner_simple_form" model="ir.ui.view">
<field name="name">base_usability.title.on.partner.simplified.form</field>
<field name="model">res.partner</field>

View File

@@ -16,6 +16,10 @@
<field name="bank_name" position="after">
<field name="bank_id"/>
</field>
<field name="acc_holder_name" position="attributes">
<attribute name="invisible">0</attribute>
<attribute name="optional">hide</attribute>
</field>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,16 @@
diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js
index e4c1b187169..ccd8110478f 100644
--- a/addons/web/static/src/js/views/form/form_renderer.js
+++ b/addons/web/static/src/js/views/form/form_renderer.js
@@ -516,7 +516,10 @@ var FormRenderer = BasicRenderer.extend({
* @returns {integer}
*/
_renderButtonBoxNbButtons: function () {
- return [2, 2, 2, 4][config.device.size_class] || 7;
+ /* AKRETION HACK 24/04/2024
+ * show 14 buttons before adding 'More' dropdown list (instead of 7 by default
+ */
+ return [2, 2, 2, 4][config.device.size_class] || 14;
},
/**
* Do not render a field widget if it is always invisible.

View File

@@ -22,6 +22,7 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
'depends': ['delivery'],
'data': [
'views/stock_picking.xml',
'views/product_packaging.xml',
],
'installable': True,
}

View File

@@ -1 +1,4 @@
from . import product_packaging
from . import stock_picking
from . import stock_move
from . import stock_quant_package

View File

@@ -0,0 +1,31 @@
# Copyright 2018-2021 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ProductPackaging(models.Model):
_inherit = 'product.packaging'
# product.packaging is defined in the 'product' module and enhanced in the 'delivery' module
# I used to make the improvements on the datamodel of product.packaging in the OCA module
# 'stock_packaging_usability_pp' from OCA/stock-logistics-tracking,
# but I eventually figured out that the feature provided by 'stock_packaging_usability_pp'
# was native in the 'delivery' module via the wizard choose.delivery.package.
# So I stopped using 'stock_packaging_usability_pp' and I moved the datamodel changes
# here in the module 'delivery_usability'
name = fields.Char(translate=True)
weight = fields.Float(digits="Stock Weight", string="Empty Package Weight")
active = fields.Boolean(default=True)
# packaging_type is important, in particular for pallets for which
# we need a special implementation to enter the height
packaging_type = fields.Selection(
[
("unit", "Unit"),
("pack", "Pack"),
("box", "Box"),
("pallet", "Pallet"),
],
string="Type",
)

View File

@@ -0,0 +1,23 @@
# Copyright 2019 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class StockMove(models.Model):
_inherit = "stock.move"
# Fixing bug https://github.com/odoo/odoo/issues/34702
@api.depends("product_id", "product_uom_qty", "product_uom")
def _cal_move_weight(self):
weight_uom_categ = self.env.ref("uom.product_uom_categ_kgm")
kg_uom = self.env.ref("uom.product_uom_kgm")
for move in self:
if move.product_id.uom_id.category_id == weight_uom_categ:
move.weight = move.product_id.uom_id._compute_quantity(
move.product_qty, kg_uom
)
else:
move.weight = move.product_qty * move.product_id.weight

View File

@@ -0,0 +1,68 @@
# Copyright 2019-2024 Akretion France (https://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
from odoo.tools import float_is_zero
class StockQuantPackage(models.Model):
_inherit = "stock.quant.package"
# These 2 fields are defined in the 'delivery' module but they forgot
# the decimal precision
shipping_weight = fields.Float(digits="Stock Weight")
weight = fields.Float(digits="Stock Weight")
# Fixing bug https://github.com/odoo/odoo/issues/34702
# and take into account the weight of the packaging
# WARNING: this method _compute_weight() is also inherited by the OCA module
# base_delivery_carrier_label so if you use that module, you should copy
# that piece of code in a custom module that depend on delivery_usability
# and base_delivery_carrier_label
def _compute_weight(self):
smlo = self.env["stock.move.line"]
weight_uom_categ = self.env.ref("uom.product_uom_categ_kgm")
kg_uom = self.env.ref("uom.product_uom_kgm")
weight_prec = self.env['decimal.precision'].precision_get('Stock Weight')
for package in self:
# if the weight of the package has been measured,
# it is written in shipping_weight
if not float_is_zero(package.shipping_weight, precision_digits=weight_prec):
weight = package.shipping_weight
# otherwise, we compute the theorical weight from the weight of the products
# and the weight of the packaging
# Since Odoo v11, consu products don't create quants, so I can't loop
# on pack.quant_ids to get all the items inside a package: I have to
# get the picking, then loop on the stock.move.line of that picking
# linked to that package
else:
weight = 0.0
# the package can be seen in a return
# So I get the picking of it's first appearance
domain = [
("result_package_id", "=", package.id),
("product_id", "!=", False),
]
first_move_line = smlo.search(
domain + [('picking_id', '!=', False)], limit=1, order='id')
if first_move_line:
picking_id = first_move_line.picking_id.id
current_picking_move_line_ids = smlo.search(
domain + [("picking_id", "=", picking_id)])
for ml in current_picking_move_line_ids:
if ml.product_uom_id.category_id == weight_uom_categ:
weight += ml.product_uom_id._compute_quantity(
ml.qty_done, kg_uom
)
else:
weight += (
ml.product_uom_id._compute_quantity(
ml.qty_done, ml.product_id.uom_id
)
* ml.product_id.weight
)
if package.packaging_id:
weight += package.packaging_id.weight
package.weight = weight

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2019-2024 Akretion France (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<!-- I don't know why the form view of product.packaging in the delivery
module has "<field name="inherit_id" eval="False"/>"
instead of a standard inherit of product.product_packaging_form_view -->
<record id="product_packaging_delivery_form" model="ir.ui.view">
<field name="name">stock_packaging_usability_pp.product.packaging.form</field>
<field name="model">product.packaging</field>
<field name="inherit_id" ref="delivery.product_packaging_delivery_form" />
<field name="arch" type="xml">
<field name="package_carrier_type" position="after">
<field name="packaging_type" />
<field name="active" invisible="1" />
</field>
<label for="max_weight" position="before">
<label for="weight" />
<div class="o_row" name="weight">
<field name="weight" />
<span><field name="weight_uom_name" /></span>
</div>
</label>
<label for="name" position="before">
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
</label>
</field>
</record>
<record id="product_packaging_delivery_tree" model="ir.ui.view">
<field name="name">stock_packaging_usability_pp.product.packaging.tree</field>
<field name="model">product.packaging</field>
<field name="inherit_id" ref="delivery.product_packaging_delivery_tree" />
<field name="arch" type="xml">
<field name="name" position="after">
<field name="packaging_type" optional="show" />
</field>
<field name="max_weight" position="before">
<field name="weight" optional="show" />
</field>
</field>
</record>
<!-- There is no native serch view for product.packaging -->
<record id="product_packaging_search" model="ir.ui.view">
<field name="name">product.packaging.search</field>
<field name="model">product.packaging</field>
<field name="arch" type="xml">
<search>
<field name="name" />
<separator />
<filter
string="Archived"
name="inactive"
domain="[('active', '=', False)]"
/>
<group name="groupby">
<filter
name="packaging_type_groupby"
string="Packaging Type"
context="{'group_by': 'packaging_type'}"
/>
</group>
</search>
</field>
</record>
</odoo>

View File

@@ -20,10 +20,10 @@ This module has been written by Alexis de Lattre from Akretion
<alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'website': 'https://github.com/akretion/odoo-usability',
'depends': ['mass_mailing', 'link_tracker_usability'],
'data': [
# 'views/link_tracker.xml',
'views/link_tracker.xml',
],
'installable': False,
'installable': True,
}

View File

@@ -0,0 +1 @@
from . import mailing_mailing

View File

@@ -0,0 +1,14 @@
# Copyright 2023 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
class MassMailing(models.Model):
_inherit = 'mailing.mailing'
def action_view_clicked(self):
action = super().action_view_clicked()
action["view_mode"] = "tree,form"
return action

View File

@@ -8,39 +8,13 @@
<odoo>
<record id="view_link_tracker_click_tree" model="ir.ui.view">
<record id="link_tracker_click_view_tree" model="ir.ui.view">
<field name="name">mm.usability.link.tracker.click.tree</field>
<field name="model">link.tracker.click</field>
<field name="inherit_id" ref="link_tracker.view_link_tracker_click_tree"/>
<field name="inherit_id" ref="mass_mailing.link_tracker_click_view_tree"/>
<field name="arch" type="xml">
<field name="country_id" position="after">
<field name="mass_mailing_id"/>
<field name="mail_stat_recipient"/>
</field>
</field>
</record>
<record id="view_link_tracker_click_form" model="ir.ui.view">
<field name="name">mm.usability.link.tracker.click.form</field>
<field name="model">link.tracker.click</field>
<field name="inherit_id" ref="link_tracker.view_link_tracker_click_form"/>
<field name="arch" type="xml">
<field name="country_id" position="after">
<field name="mass_mailing_id"/>
<field name="mass_mailing_campaign_id"/>
<field name="mail_stat_id"/>
<field name="mail_stat_recipient"/>
</field>
</field>
</record>
<record id="link_tracker_click_search" model="ir.ui.view">
<field name="name">mm.usability.link.tracker.click.search</field>
<field name="model">link.tracker.click</field>
<field name="inherit_id" ref="link_tracker_usability.link_tracker_click_search"/>
<field name="arch" type="xml">
<field name="link_id" position="after">
<field name="mail_stat_recipient"/>
<field name="mass_mailing_id" position="after">
<field name="mailing_trace_id" optional="hide"/>
</field>
</field>
</record>

View File

@@ -1,10 +1,10 @@
# Copyright (C) 2016-2019 Akretion (http://www.akretion.com)
# Copyright (C) 2016-2024 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'MRP Average Cost',
'version': '12.0.1.0.0', # WARNING: we'll probably not port this module to v14, because part of its feature is now provided by the module mrp_account
'version': '14.0.1.0.0',
'category': 'Manufactuing',
'license': 'AGPL-3',
'summary': 'Update standard_price upon validation of a manufacturing order',
@@ -12,22 +12,22 @@
MRP Average Cost
================
By default, the official stock module updates the standard_price of a product that has costing_method = 'average' when validating an incoming picking. But the official 'mrp' module doesn't do that when you validate a manufactuging order.
I initially developped this module for Odoo 12.0, when the module mrp_account didn't exist, so Odoo didn't support the update of the standard cost of a manufactured product.
This module adds this feature : when you validate a manufacturing order of a product that has costing method = 'average', the standard_price of the product will be updated by taking into account the standard_price of each raw material and also a number of work hours defined on the BOM.
In the mrp_account module, you must use workcenters to take the labor costs into account. This module aims at encoding theorical labor costs on the BOM and using it to compute the cost of the finished product.
Together with this module, I recommend the use of my module product_usability, available in the same branch, which contains a backport of the model product.price.history from v8 to v7.
With this module, when you validate a manufacturing order of a product that has costing method = 'average', the standard_price of the product will be updated by taking into account the standard_price of each raw material and also a number of work hours defined on the BOM plus the extra cost defined of the BOM.
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['mrp'],
'website': 'https://github.com/akretion/odoo-usability',
'depends': ['mrp_account'],
'data': [
'security/mrp_average_cost_security.xml',
'security/ir.model.access.csv',
'data/mrp_data.xml',
'views/mrp_view.xml',
],
'installable': False,
'installable': True,
}

View File

@@ -1,11 +1,9 @@
# Copyright (C) 2016-2019 Akretion (http://www.akretion.com)
# Copyright (C) 2016-2024 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, _
import odoo.addons.decimal_precision as dp
from odoo.exceptions import UserError
from odoo.tools import float_compare, float_is_zero
from odoo.tools import float_compare
import logging
logger = logging.getLogger(__name__)
@@ -17,23 +15,19 @@ class MrpBomLabourLine(models.Model):
bom_id = fields.Many2one(
comodel_name='mrp.bom',
string='Labour Lines',
string='Bill of Material',
ondelete='cascade')
labour_time = fields.Float(
string='Labour Time',
required=True,
digits=dp.get_precision('Labour Hours'),
digits='Labour Hours',
help="Average labour time for the production of "
"items of the BOM, in hours.")
labour_cost_profile_id = fields.Many2one(
comodel_name='labour.cost.profile',
string='Labour Cost Profile',
required=True)
note = fields.Text(
string='Note')
note = fields.Text()
_sql_constraints = [(
'labour_time_positive',
@@ -44,6 +38,26 @@ class MrpBomLabourLine(models.Model):
class MrpBom(models.Model):
_inherit = 'mrp.bom'
labour_line_ids = fields.One2many(
'mrp.bom.labour.line', 'bom_id', string='Labour Lines')
total_labour_cost = fields.Float(
compute='_compute_total_labour_cost', digits='Product Price', store=True)
extra_cost = fields.Float(
tracking=True, digits='Product Price',
help="Extra cost for the production of the quantity of "
"items of the BOM, in company currency. "
"You can use this field to enter the cost of the consumables "
"that are used to produce the product but are not listed in "
"the BOM")
total_components_cost = fields.Float(
compute='_compute_total_cost', digits='Product Price')
total_cost = fields.Float(
compute='_compute_total_cost', digits='Product Price',
help="Total cost for the quantity and unit of measure of the bill of material. "
"Total Cost = Total Components Cost + Total Labour Cost + Extra Cost")
company_currency_id = fields.Many2one(
related='company_id.currency_id', string='Company Currency')
@api.depends(
'labour_line_ids.labour_time',
'labour_line_ids.labour_cost_profile_id.hour_cost')
@@ -70,107 +84,77 @@ class MrpBom(models.Model):
bom.total_components_cost = comp_cost
bom.total_cost = total_cost
labour_line_ids = fields.One2many(
'mrp.bom.labour.line', 'bom_id', string='Labour Lines')
total_labour_cost = fields.Float(
compute='_compute_total_labour_cost', readonly=True,
digits=dp.get_precision('Product Price'),
string="Total Labour Cost", store=True)
extra_cost = fields.Float(
string='Extra Cost', track_visibility='onchange',
digits=dp.get_precision('Product Price'),
help="Extra cost for the production of the quantity of "
"items of the BOM, in company currency. "
"You can use this field to enter the cost of the consumables "
"that are used to produce the product but are not listed in "
"the BOM")
total_components_cost = fields.Float(
compute='_compute_total_cost', readonly=True,
digits=dp.get_precision('Product Price'),
string='Total Components Cost')
total_cost = fields.Float(
compute='_compute_total_cost', readonly=True,
string='Total Cost',
digits=dp.get_precision('Product Price'),
help="Total Cost = Total Components Cost + "
"Total Labour Cost + Extra Cost")
company_currency_id = fields.Many2one(
related='company_id.currency_id', string='Company Currency')
@api.model
def _phantom_update_product_standard_price(self):
logger.info('Start to auto-update cost price from phantom bom')
logger.info('Start to auto-update cost price from phantom boms')
boms = self.search([('type', '=', 'phantom')])
boms.with_context(
product_price_history_origin='Automatic update of Phantom BOMs')\
.manual_update_product_standard_price()
logger.info('End of the auto-update cost price from phantom bom')
return True
boms.manual_update_product_standard_price()
logger.info('End of the auto-update cost price from phantom boms')
def manual_update_product_standard_price(self):
if 'product_price_history_origin' not in self._context:
self = self.with_context(
product_price_history_origin='Manual update from BOM')
precision = self.env['decimal.precision'].precision_get(
prec = self.env['decimal.precision'].precision_get(
'Product Price')
for bom in self:
wproduct = bom.product_id
if not wproduct:
wproduct = bom.product_tmpl_id
if float_compare(
wproduct.standard_price, bom.total_cost,
precision_digits=precision):
wproduct.with_context().write(
{'standard_price': bom.total_cost})
logger.info(
'Cost price updated to %s on product %s',
bom.total_cost, wproduct.display_name)
return True
if bom.product_id:
products = bom.product_id
else:
products = bom.product_tmpl_id.product_variant_ids
for product in products:
standard_price = product._compute_bom_price(bom)
if float_compare(product.standard_price, standard_price, precision_digits=prec):
product.write({'standard_price': standard_price})
logger.info(
'Cost price updated to %s on product %s',
standard_price, product.display_name)
class MrpBomLine(models.Model):
_inherit = 'mrp.bom.line'
standard_price = fields.Float(
related='product_id.standard_price',
readonly=True,
string='Standard Price')
standard_price = fields.Float(related='product_id.standard_price')
class ProductProduct(models.Model):
_inherit = 'product.product'
def _compute_bom_price(self, bom, boms_to_recompute=False):
# Native method of mrp_account
# WARNING dirty hack ; I hope it doesn't break too many things
self.ensure_one()
bom_cost_per_unit_in_product_uom = 0
qty_product_uom = bom.product_uom_id._compute_quantity(bom.product_qty, self.uom_id)
if qty_product_uom:
bom_cost_per_unit_in_product_uom = bom.total_cost / qty_product_uom
return bom_cost_per_unit_in_product_uom
class LabourCostProfile(models.Model):
_name = 'labour.cost.profile'
_inherit = ['mail.thread']
_inherit = ['mail.thread', 'mail.activity.mixin']
_description = 'Labour Cost Profile'
name = fields.Char(
string='Name',
required=True,
track_visibility='onchange')
tracking=True)
hour_cost = fields.Float(
string='Cost per Hour',
required=True,
digits=dp.get_precision('Product Price'),
track_visibility='onchange',
digits='Product Price',
tracking=True,
help="Labour cost per hour per person in company currency")
company_id = fields.Many2one(
comodel_name='res.company',
string='Company',
required=True,
default=lambda self: self.env['res.company']._company_default_get())
comodel_name='res.company', required=True,
default=lambda self: self.env.company)
company_currency_id = fields.Many2one(
related='company_id.currency_id',
readonly=True,
store=True,
string='Company Currency')
related='company_id.currency_id', store=True, string='Company Currency')
@api.depends('name', 'hour_cost', 'company_currency_id.symbol')
def name_get(self):
res = []
for record in self:
res.append((record.id, u'%s (%s %s)' % (
res.append((record.id, '%s (%s %s)' % (
record.name, record.hour_cost,
record.company_currency_id.symbol)))
return res
@@ -179,93 +163,27 @@ class LabourCostProfile(models.Model):
class MrpProduction(models.Model):
_inherit = 'mrp.production'
unit_cost = fields.Float(
string='Unit Cost', readonly=True,
digits=dp.get_precision('Product Price'),
help="This cost per unit in the unit of measure of the product "
"in company currency takes into account "
"the cost of the raw materials and the labour cost defined on"
"the BOM.")
company_currency_id = fields.Many2one(
related='company_id.currency_id', readonly=True,
string='Company Currency')
related='company_id.currency_id', string='Company Currency')
# extra_cost is a native field of mrp_account
# we convert it to a computed field
# extra_cost is per unit in the UoM of mrp.production (product_uom_id)
extra_cost = fields.Float(
compute='_compute_extra_cost', store=True, readonly=False,
help="For a regular production order, it takes into account the labor cost "
"and the extra cost defined on the bill of material.")
def compute_order_unit_cost(self):
self.ensure_one()
mo_total_price = 0.0 # In the UoM of the M0
labor_cost_per_unit = 0.0 # In the UoM of the product
extra_cost_per_unit = 0.0 # In the UoM of the product
subcontract_cost_per_unit = 0.0
# I read the raw materials MO, not on BOM, in order to make
# it work with the "dynamic" BOMs (few raw material are auto-added
# on the fly on MO)
prec = self.env['decimal.precision'].precision_get(
'Product Unit of Measure')
for raw_smove in self.move_raw_ids:
# I don't filter on state, in order to make it work with
# partial productions
# For partial productions, mo.product_qty is not updated
# so we compute with fully qty and we compute with all raw
# materials (consumed or not), so it gives a good price
# per unit at the end
raw_price = raw_smove.product_id.standard_price
raw_material_cost = raw_price * raw_smove.product_qty
logger.info(
'MO %s product %s: raw_material_cost=%s',
self.name, raw_smove.product_id.display_name,
raw_material_cost)
mo_total_price += raw_material_cost
if self.bom_id:
bom = self.bom_id
# if not bom.total_labour_cost:
# raise orm.except_orm(
# _('Error:'),
# _("Total Labor Cost is 0 on bill of material '%s'.")
# % bom.name)
if float_is_zero(bom.product_qty, precision_digits=prec):
raise UserError(_(
"Missing Product Quantity on bill of material '%s'.")
% bom.display_name)
bom_qty_product_uom = bom.product_uom_id._compute_quantity(
bom.product_qty, bom.product_tmpl_id.uom_id)
assert bom_qty_product_uom > 0, 'BoM qty should be positive'
labor_cost_per_unit = bom.total_labour_cost / bom_qty_product_uom
extra_cost_per_unit = bom.extra_cost / bom_qty_product_uom
if bom.type == 'subcontract':
one_finished_move = self.env['stock.move'].search([
('production_id', '=', self.id),
('product_id', '=', self.product_id.id),
('move_dest_ids', '!=', False)], limit=1)
if one_finished_move:
subcontract_cost_per_unit = one_finished_move.move_dest_ids[0].price_unit
# mo_standard_price and labor_cost_per_unit are
# in the UoM of the product (not of the MO/BOM)
mo_qty_product_uom = self.product_uom_id._compute_quantity(
self.product_qty, self.product_id.uom_id)
assert mo_qty_product_uom > 0, 'MO qty should be positive'
mo_standard_price = mo_total_price / mo_qty_product_uom
logger.info(
'MO %s: labor_cost_per_unit=%s extra_cost_per_unit=%s '
'subcontract_cost_per_unit=%s',
self.name, labor_cost_per_unit, extra_cost_per_unit,
subcontract_cost_per_unit)
mo_standard_price += labor_cost_per_unit
mo_standard_price += extra_cost_per_unit
mo_standard_price += subcontract_cost_per_unit
return mo_standard_price
# Strategy for v14 : we write labor costs and bom's extra cost on the native field extra_cost
# of mrp.production => it is automatically added by the code of mrp_account
def post_inventory(self):
'''This is the method where _action_done() is called on finished move
So we write on 'price_unit' of the finished move and THEN we call
super() which will call _action_done() which itself calls
product_price_update_before_done()'''
for order in self:
if order.product_id.cost_method == 'average':
unit_cost = order.compute_order_unit_cost()
order.write({'unit_cost': unit_cost})
logger.info('MO %s: unit_cost=%s', order.name, unit_cost)
order.move_finished_ids.filtered(
lambda x: x.product_id == order.product_id).write({
'price_unit': unit_cost})
return super(MrpProduction, self).post_inventory()
@api.depends('bom_id', 'product_id')
def _compute_extra_cost(self):
for prod in self:
bom = prod.bom_id
if bom and bom.type == 'normal' and bom.product_uom_id.category_id == prod.product_uom_id.category_id:
extra_cost_bom_qty_uom = bom.extra_cost + bom.total_labour_cost
extra_cost_per_unit_in_prod_uom = 0
qty_prod_uom = bom.product_uom_id._compute_quantity(bom.product_qty, prod.product_uom_id)
if qty_prod_uom:
extra_cost_per_unit_in_prod_uom = extra_cost_bom_qty_uom / qty_prod_uom
prod.extra_cost = extra_cost_per_unit_in_prod_uom

View File

@@ -4,7 +4,7 @@
<record id="labour_cost_profile_rule" model="ir.rule">
<field name="name">Labour Cost Profile multi-company</field>
<field name="model_id" ref="model_labour_cost_profile"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
<field name="domain_force">[('company_id', 'in', company_ids + [False])]</field>
</record>
</odoo>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016-2019 Akretion (http://www.akretion.com/)
Copyright (C) 2016-2024 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
@@ -13,23 +13,25 @@
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml">
<field name="picking_type_id" position="after">
<field name="total_components_cost" widget="monetary"
options="{'currency_field': 'company_currency_id'}"/>
<field name="total_labour_cost" widget="monetary"
options="{'currency_field': 'company_currency_id'}"/>
<field name="extra_cost" widget="monetary"
options="{'currency_field': 'company_currency_id'}"/>
<label for="total_cost"/>
<div>
<field name="total_cost" widget="monetary"
options="{'currency_field': 'company_currency_id'}"
class="oe_inline"/>
<button type="object" name="manual_update_product_standard_price"
string="Update Cost Price of Product" class="oe_link"/>
</div>
<field name="company_currency_id" invisible="1"/>
</field>
<xpath expr="//page[@name='miscellaneous']/group" position="inside">
<group name="costs">
<field name="total_components_cost" widget="monetary"
options="{'currency_field': 'company_currency_id'}"/>
<field name="total_labour_cost" widget="monetary"
options="{'currency_field': 'company_currency_id'}"/>
<field name="extra_cost" widget="monetary"
options="{'currency_field': 'company_currency_id'}"/>
<label for="total_cost"/>
<div>
<field name="total_cost" widget="monetary"
options="{'currency_field': 'company_currency_id'}"
class="oe_inline"/>
<button type="object" name="manual_update_product_standard_price"
string="Update Cost Price of Product" class="oe_link"/>
</div>
<field name="company_currency_id" invisible="1"/>
</group>
</xpath>
<notebook position="inside">
<page string="Labour" name="labour_lines">
<group name="labour_lines_grp">
@@ -117,10 +119,10 @@
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="model">mrp.production</field>
<field name="arch" type="xml">
<field name="availability" position="after">
<field name="unit_cost" widget="monetary" options="{'currency_field': 'company_currency_id'}" attrs="{'invisible': [('state', '!=', 'done')]}"/>
<xpath expr="//page[@name='miscellaneous']//field[@name='origin']/.." position="inside">
<field name="extra_cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="company_currency_id" invisible="1"/>
</field>
</xpath>
</field>
</record>

View File

@@ -4,7 +4,7 @@
{
'name': 'MRP No Product Template Menu',
'version': '12.0.1.0.0',
'version': '14.0.1.0.0',
'category': 'Manufacturing',
'license': 'AGPL-3',
'summary': "Replace product.template menu entries by product.product menu",
@@ -22,9 +22,9 @@ This module has been written by Alexis de Lattre
from Akretion <alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'website': 'https://github.com/akretion/odoo-usability',
'depends': ['mrp', 'sale_purchase_no_product_template_menu'],
'auto_install': True,
'data': ['mrp_view.xml'],
'installable': False,
'installable': True,
}

View File

@@ -1,21 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016-2019 Akretion France (http://www.akretion.com/)
Copyright 2016-2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="product_product_action_mrp" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="res_model">product.product</field>
<field name="view_mode">tree,form,kanban</field>
<field name="context">{'search_default_consumable': 1, 'default_type': 'product'}</field>
</record>
<record id="mrp.menu_mrp_product_form" model="ir.ui.menu">
<field name="action" ref="product_product_action_mrp"/>
<field name="action" ref="product.product_normal_action"/>
</record>
<!-- we don't care about:
"search_default_consumable": 1 => not useful
"default_type": 'product' : stock_usability make it the default... no need to bother
-->
</odoo>

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -10,9 +10,11 @@
'summary': 'Usability improvements on mrp_subcontracting',
'author': 'Akretion',
'website': 'https://github.com/akretion/odoo-usability',
'depends': ['mrp_subcontracting'],
'depends': ['mrp_subcontracting', 'stock_usability'],
'data': [
'views/mrp_bom.xml',
'views/stock_move.xml',
'views/stock_picking.xml',
],
'installable': True,
}

View File

@@ -0,0 +1 @@
from . import stock_move

View File

@@ -0,0 +1,21 @@
# Copyright 2024 Akretion France (https://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
class StockMove(models.Model):
_inherit = 'stock.move'
subcontracting_production_id = fields.Many2one(
'mrp.production',
compute='_compute_subcontracting_production_id',
)
def _compute_subcontracting_production_id(self):
for move in self:
subcontracting_production_id = False
if move.is_subcontract and move.move_orig_ids.production_id:
subcontracting_production_id = move.move_orig_ids.production_id[-1:].id
move.subcontracting_production_id = subcontracting_production_id

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2023 Akretion France (http://www.akretion.com/)
Copyright 2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Akretion France (https://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_move_form" model="ir.ui.view">
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_form"/>
<field name="arch" type="xml">
<group name="advanced" position="inside">
<field name="is_subcontract" readonly="1" attrs="{'invisible': [('is_subcontract', '=', False)]}" groups="mrp.group_mrp_manager"/>
<field name="subcontracting_production_id" attrs="{'invisible': [('is_subcontract', '=', False)]}" groups="mrp.group_mrp_manager"/>
</group>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Akretion France (https://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_picking_form" model="ir.ui.view">
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='move_ids_without_package']/form/group" position="inside">
<field name="is_subcontract" readonly="1" attrs="{'invisible': [('is_subcontract', '=', False)]}" groups="mrp.group_mrp_manager"/>
<field name="subcontracting_production_id" attrs="{'invisible': [('is_subcontract', '=', False)]}" groups="mrp.group_mrp_manager"/>
</xpath>
</field>
</record>
</odoo>

View File

@@ -14,6 +14,7 @@
'data': [
'views/mrp_production.xml',
'views/product_template.xml',
'views/stock_move_line.xml',
# 'report/mrp_report.xml' # TODO
],
'installable': True,

View File

@@ -3,12 +3,27 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
from odoo import api, fields, models
class MrpProduction(models.Model):
_inherit = 'mrp.production'
# Allow to change the destination location until 'Mark as done'.
# Native behavior: it is only possible to change it in draft state.
location_dest_id = fields.Many2one(states={
'draft': [('readonly', False)], # native
'confirmed': [('readonly', False)], # added
'progress': [('readonly', False)], # added
'to_close': [('readonly', False)], # added
}, tracking=True)
# Add field product_categ_id for reporting only
product_categ_id = fields.Many2one(related='product_id.categ_id', store=True)
lot_producing_id = fields.Many2one(tracking=True)
location_src_id = fields.Many2one(tracking=True)
location_dest_id = fields.Many2one(tracking=True)
bom_id = fields.Many2one(tracking=True)
# Method used by the report, inherited in this module
@api.model
def get_stock_move_sold_out_report(self, move):

View File

@@ -16,8 +16,9 @@
<xpath expr="//page[@name='miscellaneous']/group/group/field[@name='location_src_id']" position="replace"/>
<xpath expr="//page[@name='miscellaneous']/group/group/field[@name='location_dest_id']" position="replace"/>
<field name="bom_id" position="after">
<field name="location_src_id" groups="stock.group_stock_multi_locations" options="{'no_create': True}" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="location_dest_id" groups="stock.group_stock_multi_locations" options="{'no_create': True}" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<!-- no need to set readonly via attrs, the readonly status is in the field definition -->
<field name="location_src_id" groups="stock.group_stock_multi_locations" options="{'no_create': True}" />
<field name="location_dest_id" groups="stock.group_stock_multi_locations" options="{'no_create': True}"/>
</field>
<xpath expr="//page[@name='miscellaneous']/group/group/field[@name='date_deadline']" position="after">
<field name="date_start"/>
@@ -40,4 +41,20 @@
</field>
</record>
<!-- Menu Manufacturing > Reporting > Manufacturing orders -->
<record id="mrp.mrp_production_report" model="ir.actions.act_window">
<!-- Change order: pivot first instead of graph -->
<field name="view_mode">pivot,graph,form</field>
</record>
<record id="view_production_pivot" model="ir.ui.view">
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.view_production_pivot"/>
<field name="arch" type="xml">
<pivot position="inside">
<field name="product_uom_qty" type="measure"/>
</pivot>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_move_line_form" model="ir.ui.view">
<field name="name">mrp_usability.stock.move.line.form</field>
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_move_line_form" />
<field name="arch" type="xml">
<field name="reference" position="before">
<field name="production_id" attrs="{'invisible': [('production_id', '=', False)]}"/>
</field>
</field>
</record>
</odoo>

View File

@@ -0,0 +1 @@
from . import res_partner

View File

@@ -0,0 +1,27 @@
# Copyright 2014-2024 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Partner Product Shortcut',
'version': '14.0.1.0.0',
'category': 'Contact Management',
'license': 'AGPL-3',
'summary': 'Adds a shortcut on partner form to the products supplied by this partner',
'description': """
Partner Product Shortcut
========================
Adds a smartbutton on partner form to the products supplied by this partner.
This is an alternative to the OCA module `partner_supplierinfo_smartbutton <https://github.com/OCA/purchase-workflow/tree/14.0/partner_supplierinfo_smartbutton>`_ which adds a smartbutton on partner form to links to the related product.supplierinfo (and not to product.template like in this module).
This module has been written by Alexis de Lattre from Akretion
<alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'https://github.com/akretion/odoo-usability',
'depends': ['product'],
'data': ['res_partner_view.xml'],
'installable': True,
}

View File

@@ -0,0 +1,38 @@
# Copyright 2014-2024 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, _
class ResPartner(models.Model):
_inherit = 'res.partner'
def _product_supplied_count(self):
for partner in self:
count = 0
sellers = self.env['product.supplierinfo'].search(
[('name', '=', partner.id)])
if sellers:
count = self.env['product.template'].search_count(
[('seller_ids', 'in', sellers.ids)])
partner.product_supplied_count = count
product_supplied_count = fields.Integer(
compute='_product_supplied_count', string="# of Products Supplied",
)
def show_supplied_products(self):
self.ensure_one()
sellers = self.env['product.supplierinfo'].search(
[('name', '=', self.id)])
ptemplates = self.env['product.template'].search(
[('seller_ids', 'in', sellers.ids)])
action = {
'name': _('Products'),
'type': "ir.actions.act_window",
"res_model": "product.template",
"view_mode": 'tree,kanban,form',
'domain': f"[('id', 'in', {ptemplates.ids})]",
}
return action

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014-2024 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">add.shortcut.to.product.variants.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button class="oe_inline oe_stat_button" type="object"
name="show_supplied_products"
icon="fa-shopping-basket"
attrs="{'invisible': [('product_supplied_count', '=', 0)]}">
<field string="Products Supplied" name="product_supplied_count"
widget="statinfo"/>
</button>
</div>
</field>
</record>
</odoo>

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -35,6 +35,7 @@ Akretion:
"views/pos_config.xml",
"views/product.xml",
"views/pos_payment_method.xml",
"views/stock_warehouse.xml",
],
"installable": True,
}

View File

@@ -0,0 +1,15 @@
diff --git a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js
index 55aa635aa10..3ae56105b44 100644
--- a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js
+++ b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js
@@ -169,7 +169,9 @@ odoo.define('point_of_sale.PaymentScreen', function (require) {
}
}
async _finalizeValidation() {
- if ((this.currentOrder.is_paid_with_cash() || this.currentOrder.get_change()) && this.env.pos.config.iface_cashdrawer) {
+ //if ((this.currentOrder.is_paid_with_cash() || this.currentOrder.get_change()) && this.env.pos.config.iface_cashdrawer) {
+ // Always open cashbox (by default, Odoo only opens cashbox for cash payments)
+ if (this.env.pos.config.iface_cashdrawer) {
this.env.pos.proxy.printer.open_cashbox();
}

View File

@@ -0,0 +1,69 @@
diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py
index 828d0bcf0f4..fd4a9e464f5 100644
--- a/addons/point_of_sale/models/pos_session.py
+++ b/addons/point_of_sale/models/pos_session.py
@@ -332,14 +332,16 @@ class PosSession(models.Model):
self._create_picking_at_end_of_session()
# Users without any accounting rights won't be able to create the journal entry. If this
# case, switch to sudo for creation and posting.
- try:
- with self.env.cr.savepoint():
- self.with_company(self.company_id)._create_account_move()
- except AccessError as e:
- if sudo:
- self.sudo().with_company(self.company_id)._create_account_move()
- else:
- raise e
+ # AKRETION HACK 20/10/2023 disable savepoint() because I get some
+ # crash upon pos session closing
+ #try:
+ # with self.env.cr.savepoint():
+ # self.with_company(self.company_id)._create_account_move()
+ #except AccessError as e:
+ # if sudo:
+ self.sudo().with_company(self.company_id)._create_account_move()
+ # else:
+ # raise e
if self.move_id.line_ids:
# Set the uninvoiced orders' state to 'done'
self.env['pos.order'].search([('session_id', '=', self.id), ('state', '=', 'paid')]).write({'state': 'done'})
@@ -506,6 +508,7 @@ class PosSession(models.Model):
sale_key = (
# account
line['income_account_id'],
+ line['income_analytic_account_id'],
# sign
-1 if line['amount'] < 0 else 1,
# for taxes
@@ -810,9 +813,14 @@ class PosSession(models.Model):
tax['account_id'] = tax_rep.account_id.id
date_order = order_line.order_id.date_order
taxes = [{'date_order': date_order, **tax} for tax in taxes]
+ # _get_product_analytic_accounts() is a method of the OCA module product_analytic
+ # from https://github.com/OCA/account-analytic
+ income_analytic_account = order_line.product_id.product_tmpl_id.with_company(
+ order_line.company_id)._get_product_analytic_accounts()['income']
return {
'date_order': order_line.order_id.date_order,
'income_account_id': get_income_account(order_line).id,
+ 'income_analytic_account_id': income_analytic_account and income_analytic_account.id or False,
'amount': order_line.price_subtotal,
'taxes': taxes,
'base_tags': tuple(tax_data['base_tags']),
@@ -860,7 +868,7 @@ class PosSession(models.Model):
return self._credit_amounts(partial_vals, amount, amount_converted)
def _get_sale_vals(self, key, amount, amount_converted):
- account_id, sign, tax_keys, base_tag_ids = key
+ account_id, analytic_account_id, sign, tax_keys, base_tag_ids = key
tax_ids = set(tax[0] for tax in tax_keys)
applied_taxes = self.env['account.tax'].browse(tax_ids)
title = 'Sales' if sign == 1 else 'Refund'
@@ -870,6 +878,7 @@ class PosSession(models.Model):
partial_vals = {
'name': name,
'account_id': account_id,
+ 'analytic_account_id': analytic_account_id,
'move_id': self.move_id.id,
'tax_ids': [(6, 0, tax_ids)],
'tax_tag_ids': [(6, 0, base_tag_ids)],

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_warehouse" model="ir.ui.view">
<field name="model">stock.warehouse</field>
<field name="inherit_id" ref="stock.view_warehouse"/>
<field name="arch" type="xml">
<field name="out_type_id" position="after">
<field name="pos_type_id"/>
</field>
</field>
</record>
</odoo>

View File

@@ -13,7 +13,9 @@ class ProductTemplate(models.Model):
('consu', 'Consumable'),
('service', 'Service'),
], string='Product Type', default='consu', required=True, tracking=True)
type = fields.Selection(compute='_compute_type', store=True, string="Type")
type = fields.Selection(
compute='_compute_type', store=True, string="Type", # native string = "Product Type"
default=False, required=False)
def _detailed_type_mapping(self):
return {}
@@ -23,3 +25,16 @@ class ProductTemplate(models.Model):
type_mapping = self._detailed_type_mapping()
for record in self:
record.type = type_mapping.get(record.detailed_type, record.detailed_type)
# to ensure compat with test and demo data
# It's not perfect, we still have a problem when installing the "stock"
# module while product_detailed_type_stock is not installed yet: it creates
# products with type = 'product' and with the inherit below, it sets detailed_type = 'product'
# but this value is only possible once product_detailed_type_stock is installed. Odoo says:
# ValueError: Wrong value for product.template.detailed_type: 'product'
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get('type') and vals['type'] != vals.get('detailed_type'):
vals['detailed_type'] = vals['type']
return super().create(vals_list)

View File

@@ -0,0 +1 @@
from . import test_detailed_type

View File

@@ -0,0 +1,34 @@
# Copyright 2024 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import SavepointCase
class TestProductDetailedType(SavepointCase):
def test_product_detailed_type(self):
p1 = self.env['product.product'].create({
'name': 'Test 1',
'detailed_type': 'service',
})
self.assertEqual(p1.type, 'service')
p2 = self.env['product.product'].create({
'name': 'Test 2',
'detailed_type': 'consu',
})
self.assertEqual(p2.type, 'consu')
def test_product_type_compat(self):
p1 = self.env['product.product'].create({
'name': 'Test 1',
'type': 'service',
})
self.assertEqual(p1.type, 'service')
self.assertEqual(p1.detailed_type, 'service')
p2 = self.env['product.product'].create({
'name': 'Test 1',
'type': 'consu',
})
self.assertEqual(p2.type, 'consu')
self.assertEqual(p2.detailed_type, 'consu')

View File

@@ -10,4 +10,4 @@ class ProductTemplate(models.Model):
detailed_type = fields.Selection(selection_add=[
('product', 'Storable Product')
], ondelete={'product': 'set default'})
], ondelete={'product': 'set default'}, default='product')

View File

@@ -1,10 +1,10 @@
# Copyright 2019 Akretion France (http://www.akretion.com)
# Copyright 2019-2024 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Sale Down Payment',
'version': '12.0.1.0.0',
'version': '14.0.1.0.0',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Link payment to sale orders',
@@ -14,7 +14,7 @@ Sale Down Payment
This module adds a link between payments and sale orders. It allows to see down payments directly on the sale order form view.
After processing a bank statement, you can start a wizard to link unreconciled incoming payments to a sale order. There is also a button *Register Payment* on the sale order.
After processing a bank statement, you can start a wizard to link unreconciled incoming payments to a sale order (NOT ported to v14 so far). There is also a button *Register Payment* on the sale order.
This module targets B2B companies that don't want to generate a down payment invoice for an advanced payment.
@@ -25,11 +25,13 @@ This module has been written by Alexis de Lattre from Akretion
'website': 'http://www.akretion.com',
'depends': ['sale'],
'data': [
'wizard/account_bank_statement_sale_view.xml',
'views/account_bank_statement.xml',
'security/ir.model.access.csv',
'wizard/account_payment_register_sale_view.xml',
# 'wizard/account_bank_statement_sale_view.xml',
# 'views/account_bank_statement.xml',
'views/sale.xml',
'views/account_move_line.xml',
'views/account_payment.xml',
],
'installable': False,
'installable': True,
}

View File

@@ -1,3 +1,4 @@
from . import sale
from . import account_move
from . import account_move_line
from . import account_payment

View File

@@ -0,0 +1,26 @@
# Copyright 2023-2024 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
class AccountMove(models.Model):
_inherit = 'account.move'
def _post(self, soft=True):
res = super()._post(soft=soft)
amlo = self.env['account.move.line']
for move in self:
if move.state == 'posted' and move.move_type == 'out_invoice':
sales = move.invoice_line_ids.sale_line_ids.order_id
if sales:
mlines = amlo.search([('sale_id', 'in', sales.ids)])
if mlines:
mlines_to_reconcile = move.line_ids.filtered(
lambda line: line.account_id ==
move.commercial_partner_id.property_account_receivable_id)
mlines_to_reconcile |= mlines
mlines_to_reconcile.remove_move_reconcile()
mlines_to_reconcile.reconcile()
return res

View File

@@ -1,4 +1,4 @@
# Copyright 2019 Akretion France (http://www.akretion.com)
# Copyright 2019-2024 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -9,24 +9,23 @@ from odoo.exceptions import ValidationError
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
sale_id = fields.Many2one('sale.order', string='Sale Order')
account_internal_type = fields.Selection(
related='account_id.user_type_id.type', store=True,
string='Account Internal Type')
sale_id = fields.Many2one(
'sale.order', string='Sale Order', check_company=True,
domain="[('partner_invoice_id', 'child_of', partner_id), ('state', '!=', 'cancel'), ('invoice_status', '!=', 'invoiced'), ('company_id', '=', company_id)]")
@api.constrains('sale_id', 'account_id')
def sale_id_check(self):
def _sale_id_check(self):
for line in self:
if line.sale_id and line.account_id.internal_type != 'receivable':
if line.sale_id and line.account_internal_type != 'receivable':
raise ValidationError(_(
"The account move line '%s' is linked to sale order '%s' "
"but it uses account '%s' which is not a receivable "
"account.")
% (line.name,
line.sale_id.name,
% (line.display_name,
line.sale_id.display_name,
line.account_id.display_name))
@api.onchange('account_id')
def sale_advance_payement_account_id_change(self):
if self.sale_id and self.account_id.user_type_id.type != 'receivable':
if self.sale_id and self.account_internal_type != 'receivable':
self.sale_id = False

View File

@@ -1,9 +1,8 @@
# Copyright 2019 Akretion France (http://www.akretion.com)
# Copyright 2019-2024 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
from odoo.tools import float_round
class AccountPayment(models.Model):
@@ -11,49 +10,24 @@ class AccountPayment(models.Model):
sale_id = fields.Many2one('sale.order', string='Sale Order')
def action_validate_invoice_payment(self):
if self.sale_id:
self.post()
else:
return super(AccountPayment, self).\
action_validate_invoice_payment()
def _get_counterpart_move_line_vals(self, invoice=False):
res = super(AccountPayment, self)._get_counterpart_move_line_vals(
invoice=invoice)
if self.sale_id:
res['sale_id'] = self.sale_id.id
return res
class AccountAbstractPayment(models.AbstractModel):
_inherit = "account.abstract.payment"
def default_get(self, fields_list):
res = super(AccountAbstractPayment, self).default_get(fields_list)
def _prepare_move_line_default_vals(self, write_off_line_vals=None):
line_vals_list = super()._prepare_move_line_default_vals(
write_off_line_vals=write_off_line_vals)
# Add to the receivable/payable line
if (
self._context.get('active_model') == 'sale.order' and
self._context.get('active_id')):
so = self.env['sale.order'].browse(self._context['active_id'])
res.update({
'amount': so.amount_total,
'currency_id': so.currency_id.id,
'payment_type': 'inbound',
'partner_id': so.partner_invoice_id.commercial_partner_id.id,
'partner_type': 'customer',
'communication': so.name,
'sale_id': so.id,
})
return res
self.sale_id and
len(line_vals_list) >= 2 and
line_vals_list[1].get('account_id') == self.destination_account_id.id):
line_vals_list[1]['sale_id'] = self.sale_id.id
return line_vals_list
def _compute_payment_amount(self, invoices=None, currency=None):
amount = super(AccountAbstractPayment, self)._compute_payment_amount(
invoices=invoices, currency=currency)
if self.sale_id:
payment_currency = currency
if not payment_currency:
payment_currency = self.sale_id.currency_id
amount = float_round(
self.sale_id.amount_total - self.sale_id.amount_down_payment,
precision_rounding=payment_currency.rounding)
return amount
def action_post(self):
super().action_post()
for pay in self:
if pay.sale_id and pay.payment_type == 'inbound':
pay._sale_down_payment_hook()
def _sale_down_payment_hook(self):
# can be used for notifications
# WAS on account.move.line on v12 ; is on account.payment on v14
self.ensure_one()

View File

@@ -1,4 +1,4 @@
# Copyright 2019 Akretion France (http://www.akretion.com)
# Copyright 2019-2024 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -9,8 +9,8 @@ from odoo.tools import float_round
class SaleOrder(models.Model):
_inherit = 'sale.order'
payment_line_ids = fields.One2many(
'account.move.line', 'sale_id', string='Advance Payments',
payment_ids = fields.One2many(
'account.payment', 'sale_id', string='Advance Payments',
readonly=True)
amount_down_payment = fields.Monetary(
compute='_compute_amount_down_payment', string='Down Payment Amount')
@@ -19,30 +19,20 @@ class SaleOrder(models.Model):
compute='_compute_amount_down_payment', string='Residual')
@api.depends(
'payment_line_ids.credit', 'payment_line_ids.debit',
'payment_line_ids.amount_currency', 'payment_line_ids.currency_id',
'payment_line_ids.date', 'currency_id')
'payment_ids.amount', 'payment_ids.currency_id', 'payment_ids.date',
'payment_ids.state', 'currency_id')
def _compute_amount_down_payment(self):
for sale in self:
down_payment = 0.0
sale_currency = sale.pricelist_id.currency_id
if sale_currency == sale.company_id.currency_id:
for pl in sale.payment_line_ids:
down_payment -= pl.balance
else:
for pl in sale.payment_line_ids:
if (
pl.currency_id and
pl.currency_id == sale_currency and
pl.amount_currency):
down_payment -= pl.amount_currency
else:
down_payment -= sale.company_id.currency_id._convert(
pl.balance, sale_currency, sale.company_id,
pl.date)
sale_currency = sale.currency_id
prec_rounding = sale_currency.rounding or 0.01
for payment in sale.payment_ids:
if payment.payment_type == 'inbound' and payment.state == 'posted':
down_payment += payment.currency_id._convert(
payment.amount, sale_currency, sale.company_id,
payment.date)
down_payment = float_round(
down_payment, precision_rounding=sale.currency_id.rounding)
down_payment, precision_rounding=prec_rounding)
sale.amount_down_payment = down_payment
sale.amount_residual = float_round(
sale.amount_total - down_payment,
precision_rounding=sale.currency_id.rounding)
sale.amount_total - down_payment, precision_rounding=prec_rounding)

View File

@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_payment_register_sale,Full access on account.payment.register.sale,model_account_payment_register_sale,account.group_account_invoice,1,1,1,1
access_account_payment_sale_user,Full access on account.payment to sale user,account.model_account_payment,sales_team.group_sale_salesman,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_account_payment_register_sale Full access on account.payment.register.sale model_account_payment_register_sale account.group_account_invoice 1 1 1 1
3 access_account_payment_sale_user Full access on account.payment to sale user account.model_account_payment sales_team.group_sale_salesman 1 1 1 1

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Akretion France (http://www.akretion.com/)
Copyright 2019-2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
@@ -13,10 +13,12 @@
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_form"/>
<field name="arch" type="xml">
<field name="invoice_id" position="after">
<field name="sale_id" attrs="{'invisible': [('account_internal_type', '!=', 'receivable')]}" domain="['|', ('partner_id', 'child_of', partner_id), ('partner_invoice_id', 'child_of', partner_id), ('state', '!=', 'cancel'), ('invoice_status', '!=', 'invoiced')]"/>
<field name="account_internal_type" invisible="1"/>
</field>
<xpath expr="//field[@name='blocked']/.." position="after">
<group string="Sale Order" name="sale" attrs="{'invisible': [('account_internal_type', '!=', 'receivable')]}">
<field name="sale_id"/>
<field name="account_internal_type" invisible="1"/>
</group>
</xpath>
</field>
</record>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Akretion France (http://www.akretion.com/)
Copyright 2018-2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
@@ -8,13 +8,13 @@
<odoo>
<record id="view_account_payment_sale_form" model="ir.ui.view">
<record id="view_account_payment_form" model="ir.ui.view">
<field name="name">account.payment.sale.form</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_invoice_form"/>
<field name="inherit_id" ref="account.view_account_payment_form"/>
<field name="arch" type="xml">
<field name="invoice_ids" position="after">
<field name="sale_id" invisible="1"/>
<field name="destination_account_id" position="after">
<field name="sale_id" attrs="{'invisible': [('is_internal_transfer', '=', True)]}"/>
</field>
</field>
</record>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Akretion France (http://www.akretion.com/)
Copyright 2019-2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
@@ -8,14 +8,6 @@
<odoo>
<record id="sale_account_payment_action" model="ir.actions.act_window">
<field name="name">Register Payment</field>
<field name="res_model">account.payment</field>
<field name="view_mode">form</field>
<field name="view_id" ref="account.view_account_payment_invoice_form"/>
<field name="target">new</field>
</record>
<record id="view_order_form" model="ir.ui.view">
<field name="name">advance_payment.sale.order.form</field>
<field name="model">sale.order</field>
@@ -23,7 +15,7 @@
<field name="arch" type="xml">
<notebook position="inside">
<page name="advance_payment" string="Advance Payments">
<field name="payment_line_ids" nolabel="1"/>
<field name="payment_ids" nolabel="1" colspan="2"/>
<field name="amount_residual" invisible="1"/>
</page>
</notebook>
@@ -34,7 +26,7 @@
<field name="amount_down_payment" nolabel="1" class="oe_subtotal_footer_separator"/>
</field>
<button name="action_cancel" position="before">
<button type="action" name="%(sale_account_payment_action)d" string="Register Payment" attrs="{'invisible': ['|', ('amount_residual', '&lt;=', 0), ('invoice_status', '=', 'invoiced')]}"/>
<button type="action" name="%(sale_down_payment.account_payment_register_sale_action)d" string="Register Payment" attrs="{'invisible': ['|', ('amount_residual', '&lt;=', 0), ('invoice_status', '=', 'invoiced')]}"/>
</button>
</field>
</record>

View File

@@ -1 +1,2 @@
from . import account_bank_statement_sale
from . import account_payment_register_sale
# from . import account_bank_statement_sale

View File

@@ -64,7 +64,9 @@ class AccountBankStatementSale(models.TransientModel):
self.ensure_one()
for line in self.line_ids:
if line.move_line_id.sale_id != line.sale_id:
line.move_line_id.sale_id = line.sale_id.id
line.move_line_id.write({'sale_id': line.sale_id.id or False})
if line.sale_id:
line.move_line_id._sale_down_payment_hook()
class AccountBankStatementSaleLine(models.TransientModel):

View File

@@ -0,0 +1,62 @@
# Copyright 2024 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class AccountPaymentRegisterSale(models.TransientModel):
_name = 'account.payment.register.sale'
_description = "Register a payment from a sale.order"
_check_company_auto = True
sale_id = fields.Many2one(
"sale.order", string="Sale Order",
check_company=True, readonly=True, required=True)
company_id = fields.Many2one('res.company', required=True)
journal_id = fields.Many2one(
'account.journal', string="Journal", check_company=True, required=True,
domain="[('company_id', '=', company_id), ('type', 'in', ('bank', 'cash'))]")
amount = fields.Monetary(required=True)
currency_id = fields.Many2one('res.currency', required=True)
date = fields.Date(default=fields.Date.context_today, required=True)
ref = fields.Char()
@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
if self._context.get('active_model') == 'sale.order' and self._context.get('active_id'):
sale = self.env['sale.order'].browse(self._context['active_id'])
res.update({
'sale_id': sale.id,
'company_id': sale.company_id.id,
'amount': sale.amount_total,
'currency_id': sale.currency_id.id,
})
return res
def run(self):
self.ensure_one()
pay_vals = {
'company_id': self.company_id.id,
'sale_id': self.sale_id.id,
'date': self.date,
'amount': self.amount,
'payment_type': 'inbound',
'partner_type': 'customer',
'ref': self.ref,
'journal_id': self.journal_id.id,
'currency_id': self.currency_id.id,
'partner_id': self.sale_id.partner_invoice_id.commercial_partner_id.id,
'payment_method_id': self.env.ref('account.account_payment_method_manual_in').id,
}
payment = self.env['account.payment'].create(pay_vals)
payment.action_post()
@api.onchange("journal_id")
def journal_id_change(self):
if (
self.journal_id and
self.journal_id.currency_id and
self.journal_id.currency_id != self.currency_id):
self.currency_id = self.journal_id.currency_id.id

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="account_payment_register_sale_form" model="ir.ui.view">
<field name="model">account.payment.register.sale</field>
<field name="arch" type="xml">
<form>
<group name="main">
<field name="sale_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="date"/>
<field name="journal_id" widget="selection"/>
<label for="amount"/>
<div name="amount" class="o_row">
<field name="amount"/>
<field name="currency_id" options="{'no_create': True, 'no_open': True}" groups="base.group_multi_currency"/>
</div>
<field name="ref"/>
</group>
<footer>
<button name="run" type="object" string="Register Payment" class="btn-primary"/>
<button special="cancel" string="Cancel"/>
</footer>
</form>
</field>
</record>
<record id="account_payment_register_sale_action" model="ir.actions.act_window">
<field name="name">Register Payment from Sale Order</field>
<field name="res_model">account.payment.register.sale</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>

View File

@@ -1,2 +1 @@
from . import sale
from . import sale_report
from . import models

View File

@@ -4,12 +4,12 @@
{
'name': 'Sale Margin No Onchange',
'version': '12.0.1.0.0',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Copy standard price on sale order line and compute margins',
'description': """
"name": "Sale Margin No Onchange",
"version": "14.0.1.0.0",
"category": "Sales",
"license": "AGPL-3",
"summary": "Copy standard price on sale order line and compute margins",
"description": """
This module copies the field *standard_price* of the product on the sale order line when the sale order line is created and then computes the margin of the sale order and the sale order line (in the currency of the quotation, in the currency of the company and the margin rate).
I decided to develop this module as an alternative to the OCA sale margin modules because I wanted a small and simple module. The module *account_invoice_margin*, available in the same Github repository, do the same thing on customer invoices.
@@ -17,9 +17,9 @@ I decided to develop this module as an alternative to the OCA sale margin module
This module has been written by Alexis de Lattre from Akretion
<alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['sale'],
'data': ['sale_view.xml'],
'installable': False,
"author": "Akretion",
"website": "http://www.akretion.com",
"depends": ["sale"],
"data": ["views/sale_view.xml"],
"installable": True,
}

View File

@@ -0,0 +1,2 @@
from . import sale
from . import sale_report

View File

@@ -4,7 +4,6 @@
from odoo import api, fields, models
import odoo.addons.decimal_precision as dp
class SaleOrderLine(models.Model):
@@ -16,23 +15,23 @@ class SaleOrderLine(models.Model):
store=True, string='Company Currency')
standard_price_company_currency = fields.Float(
string='Cost Price in Company Currency', readonly=True,
digits=dp.get_precision('Product Price'),
digits="Product Price",
help="Cost price in company currency in the unit of measure "
"of the sale order line")
standard_price_sale_currency = fields.Float(
string='Cost Price in Sale Currency', readonly=True,
string='Cost Price in Sale Currency',
compute='_compute_margin', store=True,
digits=dp.get_precision('Product Price'),
digits="Product Price",
help="Cost price in sale currency in the unit of measure "
"of the sale order line")
margin_sale_currency = fields.Monetary(
string='Margin in Sale Currency', readonly=True, store=True,
string='Margin in Sale Currency', store=True,
compute='_compute_margin', currency_field='currency_id')
margin_company_currency = fields.Monetary(
string='Margin in Company Currency', readonly=True, store=True,
string='Margin in Company Currency', store=True,
compute='_compute_margin', currency_field='company_currency_id')
margin_rate = fields.Float(
string="Margin Rate", readonly=True, store=True,
string="Margin Rate", store=True,
compute='_compute_margin',
digits=(16, 2), help="Margin rate in percentage of the sale price")
@@ -68,19 +67,20 @@ class SaleOrderLine(models.Model):
line.margin_rate = margin_rate
# We want to copy standard_price on sale order line
@api.model
def create(self, vals):
if vals.get('product_id'):
pp = self.env['product.product'].browse(vals['product_id'])
std_price = pp.standard_price
sale_uom_id = vals.get('product_uom')
if sale_uom_id and sale_uom_id != pp.uom_id.id:
sale_uom = self.env['uom.uom'].browse(sale_uom_id)
# convert from product UoM to sale UoM
std_price = pp.uom_id._compute_price(
pp.standard_price, sale_uom)
vals['standard_price_company_currency'] = std_price
return super(SaleOrderLine, self).create(vals)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get('product_id'):
pp = self.env['product.product'].browse(vals['product_id'])
std_price = pp.standard_price
sale_uom_id = vals.get('product_uom')
if sale_uom_id and sale_uom_id != pp.uom_id.id:
sale_uom = self.env['uom.uom'].browse(sale_uom_id)
# convert from product UoM to sale UoM
std_price = pp.uom_id._compute_price(
pp.standard_price, sale_uom)
vals['standard_price_company_currency'] = std_price
return super().create(vals_list)
def write(self, vals):
if not vals:
@@ -101,7 +101,7 @@ class SaleOrderLine(models.Model):
if sale_uom != pp.uom_id:
std_price = pp.uom_id._compute_price(std_price, sale_uom)
sol.write({'standard_price_company_currency': std_price})
return super(SaleOrderLine, self).write(vals)
return super().write(vals)
class SaleOrder(models.Model):
@@ -114,21 +114,27 @@ class SaleOrder(models.Model):
margin_sale_currency = fields.Monetary(
string='Margin in Sale Currency',
currency_field='currency_id',
readonly=True, compute='_compute_margin', store=True)
compute='_compute_margin', store=True)
margin_company_currency = fields.Monetary(
string='Margin in Company Currency',
currency_field='company_currency_id',
readonly=True, compute='_compute_margin', store=True)
compute='_compute_margin', store=True)
@api.depends(
'order_line.margin_sale_currency',
'order_line.margin_company_currency')
def _compute_margin(self):
rg_res = self.env['sale.order.line'].read_group(
[('order_id', 'in', self.ids)],
['order_id', 'margin_sale_currency:sum', 'margin_company_currency:sum'],
['order_id'])
mapped_data = dict([
(x['order_id'][0], {
'margin_sale_currency': x['margin_sale_currency'],
'margin_company_currency': x['margin_company_currency'],
}) for x in rg_res])
for order in self:
margin_sale_cur = 0.0
margin_comp_cur = 0.0
for sol in order.order_line:
margin_sale_cur += sol.margin_sale_currency
margin_comp_cur += sol.margin_company_currency
order.margin_sale_currency = margin_sale_cur
order.margin_company_currency = margin_comp_cur
order.margin_sale_currency = mapped_data.get(
order.id, {}).get('margin_sale_currency')
order.margin_company_currency = mapped_data.get(
order.id, {}).get('margin_company_currency')

Some files were not shown because too many files have changed in this diff Show More