From 07dabf150dfbfc8f69670ee8fad397b7600d3c1f Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Fri, 15 May 2020 15:12:20 +0200
Subject: [PATCH 01/35] [ADD]account_move_line_sale_info
---
account_move_line_sale_info/README.rst | 65 ++++++
account_move_line_sale_info/__init__.py | 4 +
account_move_line_sale_info/__manifest__.py | 20 ++
account_move_line_sale_info/hooks.py | 39 ++++
.../models/__init__.py | 6 +
.../models/account_invoice.py | 28 +++
.../models/account_move.py | 23 ++
.../models/sale_order_line.py | 20 ++
.../models/stock_move.py | 16 ++
.../security/account_security.xml | 10 +
.../static/description/icon.png | Bin 0 -> 9455 bytes
account_move_line_sale_info/tests/__init__.py | 3 +
.../tests/test_account_move_line_sale_info.py | 210 ++++++++++++++++++
.../views/account_move_view.xml | 70 ++++++
14 files changed, 514 insertions(+)
create mode 100644 account_move_line_sale_info/README.rst
create mode 100644 account_move_line_sale_info/__init__.py
create mode 100644 account_move_line_sale_info/__manifest__.py
create mode 100644 account_move_line_sale_info/hooks.py
create mode 100644 account_move_line_sale_info/models/__init__.py
create mode 100644 account_move_line_sale_info/models/account_invoice.py
create mode 100644 account_move_line_sale_info/models/account_move.py
create mode 100644 account_move_line_sale_info/models/sale_order_line.py
create mode 100644 account_move_line_sale_info/models/stock_move.py
create mode 100644 account_move_line_sale_info/security/account_security.xml
create mode 100644 account_move_line_sale_info/static/description/icon.png
create mode 100644 account_move_line_sale_info/tests/__init__.py
create mode 100644 account_move_line_sale_info/tests/test_account_move_line_sale_info.py
create mode 100644 account_move_line_sale_info/views/account_move_view.xml
diff --git a/account_move_line_sale_info/README.rst b/account_move_line_sale_info/README.rst
new file mode 100644
index 000000000..bd79bd9d8
--- /dev/null
+++ b/account_move_line_sale_info/README.rst
@@ -0,0 +1,65 @@
+.. image:: https://img.shields.io/badge/license-AGPLv3-blue.svg
+ :target: https://www.gnu.org/licenses/agpl.html
+ :alt: License: AGPL-3
+
+===========================
+Account Move Line Sale Info
+===========================
+
+This module will add the sale order line to journal items.
+
+The ultimate goal is to establish the purchase order line as one of the key
+fields to reconcile the Goods Delivered Not Invoiced accrual account.
+
+
+Usage
+=====
+
+The sale order line will be automatically copied to the journal items.
+
+* When a supplier invoice is created referencing sales orders, the
+ sale order line will be copied to the corresponding journal item.
+
+* When a stock move is validated and generates a journal entry, the sale
+ order line is copied to the account move line.
+
+.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
+ :alt: Try me on Runbot
+ :target: https://runbot.odoo-community.org/runbot/92/11.0
+
+Bug Tracker
+===========
+
+Bugs are tracked on `GitHub Issues
+`_. In case of trouble, please
+check there if your issue has already been reported. If you spotted it first,
+help us smashing it by providing a detailed and welcomed feedback.
+
+
+Credits
+=======
+
+Images
+------
+
+* Odoo Community Association: `Icon `_.
+
+Contributors
+------------
+
+* Aaron Henriquez
+
+Maintainer
+----------
+
+.. image:: https://odoo-community.org/logo.png
+ :alt: Odoo Community Association
+ :target: https://odoo-community.org
+
+This module is maintained by the OCA.
+
+OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
+To contribute to this module, please visit https://odoo-community.org.
diff --git a/account_move_line_sale_info/__init__.py b/account_move_line_sale_info/__init__.py
new file mode 100644
index 000000000..e66fb1c2e
--- /dev/null
+++ b/account_move_line_sale_info/__init__.py
@@ -0,0 +1,4 @@
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from . import models
+from .hooks import post_init_hook
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
new file mode 100644
index 000000000..c7c4b8533
--- /dev/null
+++ b/account_move_line_sale_info/__manifest__.py
@@ -0,0 +1,20 @@
+# Copyright 2020 ForgeFlow S.L.
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+{
+ "name": "Account Move Line Sale Info",
+ "summary": "Introduces the purchase order line to the journal items",
+ "version": "11.0.1.0.0",
+ "author": "ForgeFlow S.L., "
+ "Odoo Community Association (OCA)",
+ "website": "http://www.github.com/OCA/account-financial-tools",
+ "category": "Generic",
+ "depends": ["account", "sale"],
+ "license": "AGPL-3",
+ "data": [
+ "security/account_security.xml",
+ "views/account_move_view.xml",
+ ],
+ 'installable': True,
+ 'post_init_hook': 'post_init_hook',
+}
diff --git a/account_move_line_sale_info/hooks.py b/account_move_line_sale_info/hooks.py
new file mode 100644
index 000000000..d3761b94b
--- /dev/null
+++ b/account_move_line_sale_info/hooks.py
@@ -0,0 +1,39 @@
+# Copyright 2019 ForgeFlow S.L.
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+import ast
+from odoo import api, SUPERUSER_ID
+
+
+def post_init_hook(cr, registry):
+
+ """ INIT sale references in acount move line """
+ # FOR stock moves
+ cr.execute("""
+ update account_move_line aml set sale_line_id = sm.sale_line_id
+ FROM account_move_line aml2
+ INNER JOIN stock_move sm ON
+ aml2.stock_move_id = sm.id
+ WHERE aml.id = aml2.id;
+ """)
+ # FOR invoices
+ cr.execute("""
+ update account_move_line aml set sale_line_id = sol.id
+ FROM account_move_line aml2
+ INNER JOIN account_invoice ai ON
+ ai.id = aml2.invoice_id
+ INNER JOIN account_invoice_line ail ON
+ ail.invoice_id = ai.id
+ INNER JOIN sale_order_line_invoice_rel rel ON
+ rel.invoice_line_id = ail.id
+ INNER JOIN sale_order_line sol ON
+ rel.order_line_id = sol.id
+ WHERE aml.id = aml2.id;
+ """)
+
+ # NOW we can fill the SO
+ cr.execute("""
+ UPDATE account_move_line aml
+ SET sale_id = sol.order_id
+ FROM sale_order_line AS sol
+ WHERE aml.sale_line_id = sol.id
+ """)
diff --git a/account_move_line_sale_info/models/__init__.py b/account_move_line_sale_info/models/__init__.py
new file mode 100644
index 000000000..f4c1f16e6
--- /dev/null
+++ b/account_move_line_sale_info/models/__init__.py
@@ -0,0 +1,6 @@
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from . import account_move
+from . import account_invoice
+from . import sale_order_line
+from . import stock_move
diff --git a/account_move_line_sale_info/models/account_invoice.py b/account_move_line_sale_info/models/account_invoice.py
new file mode 100644
index 000000000..859b45247
--- /dev/null
+++ b/account_move_line_sale_info/models/account_invoice.py
@@ -0,0 +1,28 @@
+# Copyright 2020 ForgeFlow S.L.
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from odoo import api, models
+
+
+class AccountInvoice(models.Model):
+
+ _inherit = 'account.invoice'
+
+ @api.model
+ def invoice_line_move_line_get(self):
+ res = super(AccountInvoice, self).invoice_line_move_line_get()
+
+ invoice_line_model = self.env['account.invoice.line']
+ for move_line_dict in res:
+ if 'invl_id' in move_line_dict:
+ line = invoice_line_model.browse(move_line_dict['invl_id'])
+ if line.sale_line_ids and len(line.sale_line_ids) == 1:
+ move_line_dict['sale_line_id'] = line.sale_line_ids[0].id
+ return res
+
+ @api.model
+ def line_get_convert(self, line, part):
+ res = super(AccountInvoice, self).line_get_convert(line, part)
+ if line.get('sale_line_id', False):
+ res['sale_line_id'] = line.get('sale_line_id')
+ return res
diff --git a/account_move_line_sale_info/models/account_move.py b/account_move_line_sale_info/models/account_move.py
new file mode 100644
index 000000000..01f083681
--- /dev/null
+++ b/account_move_line_sale_info/models/account_move.py
@@ -0,0 +1,23 @@
+# Copyright 2020 ForgeFlow S.L.
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from odoo import fields, models
+
+
+class AccountMoveLine(models.Model):
+
+ _inherit = 'account.move.line'
+
+ sale_line_id = fields.Many2one(
+ comodel_name='sale.order.line',
+ string='Sale Order Line',
+ ondelete='set null', index=True,
+ )
+
+ sale_id = fields.Many2one(
+ comodel_name='sale.order',
+ related='sale_line_id.order_id',
+ string='Sales Order',
+ ondelete='set null',
+ store=True, index=True,
+ )
diff --git a/account_move_line_sale_info/models/sale_order_line.py b/account_move_line_sale_info/models/sale_order_line.py
new file mode 100644
index 000000000..ccb9043c4
--- /dev/null
+++ b/account_move_line_sale_info/models/sale_order_line.py
@@ -0,0 +1,20 @@
+# Copyright 2020 ForgeFlow S.L.
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from odoo import api, models
+
+
+class SaleOrderLine(models.Model):
+ _inherit = "sale.order.line"
+
+ @api.multi
+ def name_get(self):
+ result = []
+ orig_name = dict(super(SaleOrderLine, self).name_get())
+ for line in self:
+ name = orig_name[line.id]
+ if self.env.context.get('so_line_info', False):
+ name = "[%s] %s (%s)" % (line.order_id.name, name,
+ line.order_id.state)
+ result.append((line.id, name))
+ return result
diff --git a/account_move_line_sale_info/models/stock_move.py b/account_move_line_sale_info/models/stock_move.py
new file mode 100644
index 000000000..a346a0168
--- /dev/null
+++ b/account_move_line_sale_info/models/stock_move.py
@@ -0,0 +1,16 @@
+# Copyright 2020 ForgeFlow S.L.
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+from odoo import api, models
+
+
+class StockMove(models.Model):
+ _inherit = "stock.move"
+
+ @api.model
+ def _prepare_account_move_line(self, qty, cost,
+ credit_account_id, debit_account_id):
+ res = super(StockMove, self)._prepare_account_move_line(
+ qty, cost, credit_account_id, debit_account_id)
+ for line in res:
+ line[2]['sale_line_id'] = self.sale_line_id.id
+ return res
diff --git a/account_move_line_sale_info/security/account_security.xml b/account_move_line_sale_info/security/account_security.xml
new file mode 100644
index 000000000..a6d3ed040
--- /dev/null
+++ b/account_move_line_sale_info/security/account_security.xml
@@ -0,0 +1,10 @@
+
+
+
+
+ Sale info in Journal Items
+
+
+
+
+
diff --git a/account_move_line_sale_info/static/description/icon.png b/account_move_line_sale_info/static/description/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d
GIT binary patch
literal 9455
zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&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ig-$
zbW26Ws~IgY>}^5w`vTB(G`PTZaDiGBo5o(tp)qli|NeV(
z@H_=R8V39rt5J5YB2Ky?4eJJ#b`_iBe2ot~6%7mLt5t8Vwi^Jy7|jWXqa3amOIoRb
zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4
z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{
zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx}
z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov
zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22
zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq
zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t<
z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k
z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp
z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{}
zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N
Xviia!U7SGha1wx#SCgwmn*{w2TRX*I
literal 0
HcmV?d00001
diff --git a/account_move_line_sale_info/tests/__init__.py b/account_move_line_sale_info/tests/__init__.py
new file mode 100644
index 000000000..a2d0246f8
--- /dev/null
+++ b/account_move_line_sale_info/tests/__init__.py
@@ -0,0 +1,3 @@
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from . import test_account_move_line_sale_info
diff --git a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
new file mode 100644
index 000000000..a3eaa9745
--- /dev/null
+++ b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
@@ -0,0 +1,210 @@
+# Copyright 2020 ForgeFlow S.L.
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+from odoo.tests import common
+from odoo import fields
+
+
+class TestAccountMoveLineSaleInfo(common.TransactionCase):
+
+ def setUp(self):
+ super(TestAccountMoveLineSaleInfo, self).setUp()
+ self.sale_model = self.env['sale.order']
+ self.sale_line_model = self.env['sale.order.line']
+ self.invoice_model = self.env['account.invoice']
+ self.invoice_line_model = self.env['account.invoice.line']
+ self.product_model = self.env['product.product']
+ self.product_ctg_model = self.env['product.category']
+ self.acc_type_model = self.env['account.account.type']
+ self.account_model = self.env['account.account']
+ self.aml_model = self.env['account.move.line']
+ self.res_users_model = self.env['res.users']
+
+ self.partner1 = self.env.ref('base.res_partner_1')
+ self.location_stock = self.env.ref('stock.stock_location_stock')
+ self.company = self.env.ref('base.main_company')
+ self.group_sale_user = self.env.ref('sales_team.group_sale_salesman')
+ self.group_account_invoice = self.env.ref(
+ 'account.group_account_invoice')
+ self.group_account_manager = self.env.ref(
+ 'account.group_account_manager')
+
+ # Create account for Goods Received Not Invoiced
+ acc_type = self._create_account_type('equity', 'other')
+ name = 'Goods Received Not Invoiced'
+ code = 'grni'
+ self.account_grni = self._create_account(acc_type, name, code,
+ self.company)
+
+ # Create account for Cost of Goods Sold
+ acc_type = self._create_account_type('expense', 'other')
+ name = 'Cost of Goods Sold'
+ code = 'cogs'
+ self.account_cogs = self._create_account(acc_type, name, code,
+ self.company)
+ # Create account for Inventory
+ acc_type = self._create_account_type('asset', 'other')
+ name = 'Inventory'
+ code = 'inventory'
+ self.account_inventory = self._create_account(acc_type, name, code,
+ self.company)
+ # Create Product
+ self.product = self._create_product()
+
+ # Create users
+ self.sale_user = self._create_user('sale_user',
+ [self.group_sale_user,
+ self.group_account_invoice],
+ self.company)
+ self.account_invoice = self._create_user('account_invoice',
+ [self.group_account_invoice],
+ self.company)
+ self.account_manager = self._create_user('account_manager',
+ [self.group_account_manager],
+ self.company)
+
+ def _create_user(self, login, groups, company):
+ """ Create a user."""
+ group_ids = [group.id for group in groups]
+ user = \
+ self.res_users_model.with_context(
+ {'no_reset_password': True}).create({
+ 'name': 'Test User',
+ 'login': login,
+ 'password': 'demo',
+ 'email': 'test@yourcompany.com',
+ 'company_id': company.id,
+ 'company_ids': [(4, company.id)],
+ 'groups_id': [(6, 0, group_ids)]
+ })
+ return user.id
+
+ def _create_account_type(self, name, type):
+ acc_type = self.acc_type_model.create({
+ 'name': name,
+ 'type': type
+ })
+ return acc_type
+
+ def _create_account(self, acc_type, name, code, company):
+ """Create an account."""
+ account = self.account_model.create({
+ 'name': name,
+ 'code': code,
+ 'user_type_id': acc_type.id,
+ 'company_id': company.id
+ })
+ return account
+
+ def _create_product(self):
+ """Create a Product."""
+ # group_ids = [group.id for group in groups]
+ product_ctg = self.product_ctg_model.create({
+ 'name': 'test_product_ctg',
+ 'property_stock_valuation_account_id': self.account_inventory.id,
+ 'property_valuation': 'real_time',
+ 'property_stock_account_input_categ_id': self.account_grni.id,
+ 'property_stock_account_output_categ_id': self.account_cogs.id,
+ })
+ product = self.product_model.create({
+ 'name': 'test_product',
+ 'categ_id': product_ctg.id,
+ 'type': 'product',
+ 'standard_price': 1.0,
+ 'list_price': 1.0,
+ })
+ return product
+
+ def _create_sale(self, line_products):
+ """ Create a sale order.
+
+ ``line_products`` is a list of tuple [(product, qty)]
+ """
+ lines = []
+ for product, qty in line_products:
+ line_values = {
+ 'name': product.name,
+ 'product_id': product.id,
+ 'product_qty': qty,
+ 'product_uom': product.uom_id.id,
+ 'price_unit': 500,
+ 'date_planned': fields.datetime.now()
+ }
+ lines.append(
+ (0, 0, line_values)
+ )
+ return self.sale_model.create({
+ 'partner_id': self.partner1.id,
+ 'order_line': lines
+ })
+
+ def _get_balance(self, domain):
+ """
+ Call read_group method and return the balance of particular account.
+ """
+ aml_rec = self.aml_model.read_group(domain,
+ ['debit', 'credit', 'account_id'],
+ ['account_id'])
+ if aml_rec:
+ return aml_rec[0].get('debit', 0) - aml_rec[0].get('credit', 0)
+ else:
+ return 0.0
+
+ def _check_account_balance(self, account_id, sale_line=None,
+ expected_balance=0.0):
+ """
+ Check the balance of the account
+ """
+ domain = [('account_id', '=', account_id)]
+ if sale_line:
+ domain.extend([('sale_line_id', '=', sale_line.id)])
+
+ balance = self._get_balance(domain)
+ if sale_line:
+ self.assertEqual(balance, expected_balance,
+ 'Balance is not %s for sale Line %s.'
+ % (str(expected_balance), sale_line.name))
+
+ def test_sale_invoice(self):
+ """Test that the po line moves from the sale order to the
+ account move line and to the invoice line.
+ """
+ sale = self._create_sale([(self.product, 1)])
+ po_line = False
+ for line in sale.order_line:
+ po_line = line
+ break
+ sale.button_confirm()
+ picking = sale.picking_ids[0]
+ picking.force_assign()
+ picking.move_lines.write({'quantity_done': 1.0})
+ picking.button_validate()
+
+ expected_balance = 1.0
+ self._check_account_balance(self.account_inventory.id,
+ sale_line=po_line,
+ expected_balance=expected_balance)
+
+ invoice = self.invoice_model.create({
+ 'partner_id': self.partner1.id,
+ 'sale_id': sale.id,
+ 'account_id': sale.partner_id.property_account_payable_id.id,
+ })
+ invoice.sale_order_change()
+ invoice.action_invoice_open()
+
+ for aml in invoice.move_id.line_ids:
+ if aml.product_id == po_line.product_id and aml.invoice_id:
+ self.assertEqual(aml.sale_line_id, po_line,
+ 'sale Order line has not been copied '
+ 'from the invoice to the account move line.')
+
+ def test_name_get(self):
+ sale = self._create_sale([(self.product, 1)])
+ po_line = sale.order_line[0]
+ name_get = po_line.with_context({'po_line_info': True}).name_get()
+ self.assertEqual(name_get, [(po_line.id, "[%s] %s (%s)" % (
+ po_line.order_id.name, po_line.name,
+ po_line.order_id.state,
+ ))])
+ name_get_no_ctx = po_line.name_get()
+ self.assertEqual(name_get_no_ctx, [(po_line.id, po_line.name)])
diff --git a/account_move_line_sale_info/views/account_move_view.xml b/account_move_line_sale_info/views/account_move_view.xml
new file mode 100644
index 000000000..8fa88ec9a
--- /dev/null
+++ b/account_move_line_sale_info/views/account_move_view.xml
@@ -0,0 +1,70 @@
+
+
+
+
+ account.move.line.form
+ account.move.line
+
+
+
+
+
+
+
+
+
+
+ account.move.line.tree
+ account.move.line
+
+
+
+
+
+
+
+
+
+
+
+ Journal Items
+ account.move.line
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ account.move.form
+ account.move
+
+
+
+
+
+
+
+
+
+
From e1b1f7b35284ae0bb5a6412cce0c4a4613eb8741 Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Mon, 18 May 2020 15:34:53 +0200
Subject: [PATCH 02/35] [IMP]hook. Odoo does not add the invoice_id in payable
entries so need to use the product.
---
account_move_line_sale_info/__manifest__.py | 2 +-
account_move_line_sale_info/hooks.py | 25 +++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index c7c4b8533..85625fb5f 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -9,7 +9,7 @@
"Odoo Community Association (OCA)",
"website": "http://www.github.com/OCA/account-financial-tools",
"category": "Generic",
- "depends": ["account", "sale"],
+ "depends": ["account_move_line_stock_info", "sale"],
"license": "AGPL-3",
"data": [
"security/account_security.xml",
diff --git a/account_move_line_sale_info/hooks.py b/account_move_line_sale_info/hooks.py
index d3761b94b..3d5bbab94 100644
--- a/account_move_line_sale_info/hooks.py
+++ b/account_move_line_sale_info/hooks.py
@@ -27,6 +27,7 @@ def post_init_hook(cr, registry):
rel.invoice_line_id = ail.id
INNER JOIN sale_order_line sol ON
rel.order_line_id = sol.id
+ AND sol.product_id = aml2.product_id
WHERE aml.id = aml2.id;
""")
@@ -36,4 +37,28 @@ def post_init_hook(cr, registry):
SET sale_id = sol.order_id
FROM sale_order_line AS sol
WHERE aml.sale_line_id = sol.id
+ RETURNING aml.move_id
+ """)
+
+ # NOW we can fill the lines without invoice_id (Odoo put it very
+ # complicated)
+
+ cr.execute("""
+ UPDATE account_move_line aml
+ SET sale_id = so.id
+ FROM sale_order_line so
+ LEFT JOIN account_move_line aml2
+ ON aml2.sale_id = so.id
+ WHERE aml2.move_id = aml.move_id
+ """)
+
+ cr.execute("""
+ update account_move_line aml set sale_line_id = sol.id
+ FROM account_move_line aml2
+ INNER JOIN sale_order so ON
+ so.id = aml2.sale_id
+ INNER JOIN sale_order_line sol ON
+ so.id = sol.order_id
+ AND sol.product_id = aml2.product_id
+ WHERE aml.id = aml2.id;
""")
From c8f6f86201e7b60069b60e3033eb046235042f5e Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Wed, 20 May 2020 17:36:38 +0200
Subject: [PATCH 03/35] [UPD]Include sale line in anglosaxon entries
---
account_move_line_sale_info/models/account_invoice.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/account_move_line_sale_info/models/account_invoice.py b/account_move_line_sale_info/models/account_invoice.py
index 859b45247..41a64d682 100644
--- a/account_move_line_sale_info/models/account_invoice.py
+++ b/account_move_line_sale_info/models/account_invoice.py
@@ -26,3 +26,14 @@ class AccountInvoice(models.Model):
if line.get('sale_line_id', False):
res['sale_line_id'] = line.get('sale_line_id')
return res
+
+ @api.model
+ def _anglo_saxon_sale_move_lines(self, i_line):
+ """
+ We need to add the sale_line to those entries too
+ """
+ res = super()._anglo_saxon_sale_move_lines(i_line)
+ for aml in res:
+ if i_line.sale_line_ids and len(i_line.sale_line_ids) == 1:
+ aml['sale_line_id'] = i_line.sale_line_ids[0].id
+ return res
From 982fb1a7e9cbe2d0758ed399ec0eb8ba6e11b481 Mon Sep 17 00:00:00 2001
From: AaronHForgeFlow
Date: Wed, 29 Jul 2020 17:26:15 +0200
Subject: [PATCH 04/35] [IMP] : black, isort, prettier
---
account_move_line_sale_info/__manifest__.py | 12 +-
account_move_line_sale_info/hooks.py | 35 ++-
.../models/account_invoice.py | 16 +-
.../models/account_move.py | 20 +-
.../models/sale_order_line.py | 5 +-
.../models/stock_move.py | 10 +-
.../security/account_security.xml | 8 +-
.../tests/test_account_move_line_sale_info.py | 254 +++++++++---------
.../views/account_move_view.xml | 89 +++---
9 files changed, 244 insertions(+), 205 deletions(-)
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index 85625fb5f..98fc7507c 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -5,16 +5,12 @@
"name": "Account Move Line Sale Info",
"summary": "Introduces the purchase order line to the journal items",
"version": "11.0.1.0.0",
- "author": "ForgeFlow S.L., "
- "Odoo Community Association (OCA)",
+ "author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
"website": "http://www.github.com/OCA/account-financial-tools",
"category": "Generic",
"depends": ["account_move_line_stock_info", "sale"],
"license": "AGPL-3",
- "data": [
- "security/account_security.xml",
- "views/account_move_view.xml",
- ],
- 'installable': True,
- 'post_init_hook': 'post_init_hook',
+ "data": ["security/account_security.xml", "views/account_move_view.xml",],
+ "installable": True,
+ "post_init_hook": "post_init_hook",
}
diff --git a/account_move_line_sale_info/hooks.py b/account_move_line_sale_info/hooks.py
index 3d5bbab94..f47a472f5 100644
--- a/account_move_line_sale_info/hooks.py
+++ b/account_move_line_sale_info/hooks.py
@@ -1,22 +1,26 @@
# Copyright 2019 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import ast
-from odoo import api, SUPERUSER_ID
+
+from odoo import SUPERUSER_ID, api
def post_init_hook(cr, registry):
""" INIT sale references in acount move line """
# FOR stock moves
- cr.execute("""
+ cr.execute(
+ """
update account_move_line aml set sale_line_id = sm.sale_line_id
FROM account_move_line aml2
INNER JOIN stock_move sm ON
aml2.stock_move_id = sm.id
WHERE aml.id = aml2.id;
- """)
+ """
+ )
# FOR invoices
- cr.execute("""
+ cr.execute(
+ """
update account_move_line aml set sale_line_id = sol.id
FROM account_move_line aml2
INNER JOIN account_invoice ai ON
@@ -29,30 +33,36 @@ def post_init_hook(cr, registry):
rel.order_line_id = sol.id
AND sol.product_id = aml2.product_id
WHERE aml.id = aml2.id;
- """)
+ """
+ )
# NOW we can fill the SO
- cr.execute("""
+ cr.execute(
+ """
UPDATE account_move_line aml
SET sale_id = sol.order_id
FROM sale_order_line AS sol
WHERE aml.sale_line_id = sol.id
RETURNING aml.move_id
- """)
+ """
+ )
# NOW we can fill the lines without invoice_id (Odoo put it very
# complicated)
- cr.execute("""
+ cr.execute(
+ """
UPDATE account_move_line aml
SET sale_id = so.id
FROM sale_order_line so
LEFT JOIN account_move_line aml2
- ON aml2.sale_id = so.id
+ ON aml2.sale_id = so.id
WHERE aml2.move_id = aml.move_id
- """)
+ """
+ )
- cr.execute("""
+ cr.execute(
+ """
update account_move_line aml set sale_line_id = sol.id
FROM account_move_line aml2
INNER JOIN sale_order so ON
@@ -61,4 +71,5 @@ def post_init_hook(cr, registry):
so.id = sol.order_id
AND sol.product_id = aml2.product_id
WHERE aml.id = aml2.id;
- """)
+ """
+ )
diff --git a/account_move_line_sale_info/models/account_invoice.py b/account_move_line_sale_info/models/account_invoice.py
index 41a64d682..73d8a555e 100644
--- a/account_move_line_sale_info/models/account_invoice.py
+++ b/account_move_line_sale_info/models/account_invoice.py
@@ -6,25 +6,25 @@ from odoo import api, models
class AccountInvoice(models.Model):
- _inherit = 'account.invoice'
+ _inherit = "account.invoice"
@api.model
def invoice_line_move_line_get(self):
res = super(AccountInvoice, self).invoice_line_move_line_get()
- invoice_line_model = self.env['account.invoice.line']
+ invoice_line_model = self.env["account.invoice.line"]
for move_line_dict in res:
- if 'invl_id' in move_line_dict:
- line = invoice_line_model.browse(move_line_dict['invl_id'])
+ if "invl_id" in move_line_dict:
+ line = invoice_line_model.browse(move_line_dict["invl_id"])
if line.sale_line_ids and len(line.sale_line_ids) == 1:
- move_line_dict['sale_line_id'] = line.sale_line_ids[0].id
+ move_line_dict["sale_line_id"] = line.sale_line_ids[0].id
return res
@api.model
def line_get_convert(self, line, part):
res = super(AccountInvoice, self).line_get_convert(line, part)
- if line.get('sale_line_id', False):
- res['sale_line_id'] = line.get('sale_line_id')
+ if line.get("sale_line_id", False):
+ res["sale_line_id"] = line.get("sale_line_id")
return res
@api.model
@@ -35,5 +35,5 @@ class AccountInvoice(models.Model):
res = super()._anglo_saxon_sale_move_lines(i_line)
for aml in res:
if i_line.sale_line_ids and len(i_line.sale_line_ids) == 1:
- aml['sale_line_id'] = i_line.sale_line_ids[0].id
+ aml["sale_line_id"] = i_line.sale_line_ids[0].id
return res
diff --git a/account_move_line_sale_info/models/account_move.py b/account_move_line_sale_info/models/account_move.py
index 01f083681..d84d53cc0 100644
--- a/account_move_line_sale_info/models/account_move.py
+++ b/account_move_line_sale_info/models/account_move.py
@@ -6,18 +6,20 @@ from odoo import fields, models
class AccountMoveLine(models.Model):
- _inherit = 'account.move.line'
+ _inherit = "account.move.line"
sale_line_id = fields.Many2one(
- comodel_name='sale.order.line',
- string='Sale Order Line',
- ondelete='set null', index=True,
+ comodel_name="sale.order.line",
+ string="Sale Order Line",
+ ondelete="set null",
+ index=True,
)
sale_id = fields.Many2one(
- comodel_name='sale.order',
- related='sale_line_id.order_id',
- string='Sales Order',
- ondelete='set null',
- store=True, index=True,
+ comodel_name="sale.order",
+ related="sale_line_id.order_id",
+ string="Sales Order",
+ ondelete="set null",
+ store=True,
+ index=True,
)
diff --git a/account_move_line_sale_info/models/sale_order_line.py b/account_move_line_sale_info/models/sale_order_line.py
index ccb9043c4..fc103cc44 100644
--- a/account_move_line_sale_info/models/sale_order_line.py
+++ b/account_move_line_sale_info/models/sale_order_line.py
@@ -13,8 +13,7 @@ class SaleOrderLine(models.Model):
orig_name = dict(super(SaleOrderLine, self).name_get())
for line in self:
name = orig_name[line.id]
- if self.env.context.get('so_line_info', False):
- name = "[%s] %s (%s)" % (line.order_id.name, name,
- line.order_id.state)
+ if self.env.context.get("so_line_info", False):
+ name = "[{}] {} ({})".format(line.order_id.name, name, line.order_id.state)
result.append((line.id, name))
return result
diff --git a/account_move_line_sale_info/models/stock_move.py b/account_move_line_sale_info/models/stock_move.py
index a346a0168..07b1bb0b7 100644
--- a/account_move_line_sale_info/models/stock_move.py
+++ b/account_move_line_sale_info/models/stock_move.py
@@ -7,10 +7,12 @@ class StockMove(models.Model):
_inherit = "stock.move"
@api.model
- def _prepare_account_move_line(self, qty, cost,
- credit_account_id, debit_account_id):
+ def _prepare_account_move_line(
+ self, qty, cost, credit_account_id, debit_account_id
+ ):
res = super(StockMove, self)._prepare_account_move_line(
- qty, cost, credit_account_id, debit_account_id)
+ qty, cost, credit_account_id, debit_account_id
+ )
for line in res:
- line[2]['sale_line_id'] = self.sale_line_id.id
+ line[2]["sale_line_id"] = self.sale_line_id.id
return res
diff --git a/account_move_line_sale_info/security/account_security.xml b/account_move_line_sale_info/security/account_security.xml
index a6d3ed040..bd3f7e6d5 100644
--- a/account_move_line_sale_info/security/account_security.xml
+++ b/account_move_line_sale_info/security/account_security.xml
@@ -1,10 +1,8 @@
-
+
-
Sale info in Journal Items
-
-
+
+
-
diff --git a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
index a3eaa9745..29f62d448 100644
--- a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
+++ b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
@@ -1,117 +1,117 @@
# Copyright 2020 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from odoo.tests import common
from odoo import fields
+from odoo.tests import common
class TestAccountMoveLineSaleInfo(common.TransactionCase):
-
def setUp(self):
super(TestAccountMoveLineSaleInfo, self).setUp()
- self.sale_model = self.env['sale.order']
- self.sale_line_model = self.env['sale.order.line']
- self.invoice_model = self.env['account.invoice']
- self.invoice_line_model = self.env['account.invoice.line']
- self.product_model = self.env['product.product']
- self.product_ctg_model = self.env['product.category']
- self.acc_type_model = self.env['account.account.type']
- self.account_model = self.env['account.account']
- self.aml_model = self.env['account.move.line']
- self.res_users_model = self.env['res.users']
+ self.sale_model = self.env["sale.order"]
+ self.sale_line_model = self.env["sale.order.line"]
+ self.invoice_model = self.env["account.invoice"]
+ self.invoice_line_model = self.env["account.invoice.line"]
+ self.product_model = self.env["product.product"]
+ self.product_ctg_model = self.env["product.category"]
+ self.acc_type_model = self.env["account.account.type"]
+ self.account_model = self.env["account.account"]
+ self.aml_model = self.env["account.move.line"]
+ self.res_users_model = self.env["res.users"]
- self.partner1 = self.env.ref('base.res_partner_1')
- self.location_stock = self.env.ref('stock.stock_location_stock')
- self.company = self.env.ref('base.main_company')
- self.group_sale_user = self.env.ref('sales_team.group_sale_salesman')
- self.group_account_invoice = self.env.ref(
- 'account.group_account_invoice')
- self.group_account_manager = self.env.ref(
- 'account.group_account_manager')
+ self.partner1 = self.env.ref("base.res_partner_1")
+ self.location_stock = self.env.ref("stock.stock_location_stock")
+ self.company = self.env.ref("base.main_company")
+ self.group_sale_user = self.env.ref("sales_team.group_sale_salesman")
+ self.group_account_invoice = self.env.ref("account.group_account_invoice")
+ self.group_account_manager = self.env.ref("account.group_account_manager")
# Create account for Goods Received Not Invoiced
- acc_type = self._create_account_type('equity', 'other')
- name = 'Goods Received Not Invoiced'
- code = 'grni'
- self.account_grni = self._create_account(acc_type, name, code,
- self.company)
+ acc_type = self._create_account_type("equity", "other")
+ name = "Goods Received Not Invoiced"
+ code = "grni"
+ self.account_grni = self._create_account(acc_type, name, code, self.company)
# Create account for Cost of Goods Sold
- acc_type = self._create_account_type('expense', 'other')
- name = 'Cost of Goods Sold'
- code = 'cogs'
- self.account_cogs = self._create_account(acc_type, name, code,
- self.company)
+ acc_type = self._create_account_type("expense", "other")
+ name = "Cost of Goods Sold"
+ code = "cogs"
+ self.account_cogs = self._create_account(acc_type, name, code, self.company)
# Create account for Inventory
- acc_type = self._create_account_type('asset', 'other')
- name = 'Inventory'
- code = 'inventory'
- self.account_inventory = self._create_account(acc_type, name, code,
- self.company)
+ acc_type = self._create_account_type("asset", "other")
+ name = "Inventory"
+ code = "inventory"
+ self.account_inventory = self._create_account(
+ acc_type, name, code, self.company
+ )
# Create Product
self.product = self._create_product()
# Create users
- self.sale_user = self._create_user('sale_user',
- [self.group_sale_user,
- self.group_account_invoice],
- self.company)
- self.account_invoice = self._create_user('account_invoice',
- [self.group_account_invoice],
- self.company)
- self.account_manager = self._create_user('account_manager',
- [self.group_account_manager],
- self.company)
+ self.sale_user = self._create_user(
+ "sale_user",
+ [self.group_sale_user, self.group_account_invoice],
+ self.company,
+ )
+ self.account_invoice = self._create_user(
+ "account_invoice", [self.group_account_invoice], self.company
+ )
+ self.account_manager = self._create_user(
+ "account_manager", [self.group_account_manager], self.company
+ )
def _create_user(self, login, groups, company):
""" Create a user."""
group_ids = [group.id for group in groups]
- user = \
- self.res_users_model.with_context(
- {'no_reset_password': True}).create({
- 'name': 'Test User',
- 'login': login,
- 'password': 'demo',
- 'email': 'test@yourcompany.com',
- 'company_id': company.id,
- 'company_ids': [(4, company.id)],
- 'groups_id': [(6, 0, group_ids)]
- })
+ user = self.res_users_model.with_context({"no_reset_password": True}).create(
+ {
+ "name": "Test User",
+ "login": login,
+ "password": "demo",
+ "email": "test@yourcompany.com",
+ "company_id": company.id,
+ "company_ids": [(4, company.id)],
+ "groups_id": [(6, 0, group_ids)],
+ }
+ )
return user.id
def _create_account_type(self, name, type):
- acc_type = self.acc_type_model.create({
- 'name': name,
- 'type': type
- })
+ acc_type = self.acc_type_model.create({"name": name, "type": type})
return acc_type
def _create_account(self, acc_type, name, code, company):
"""Create an account."""
- account = self.account_model.create({
- 'name': name,
- 'code': code,
- 'user_type_id': acc_type.id,
- 'company_id': company.id
- })
+ account = self.account_model.create(
+ {
+ "name": name,
+ "code": code,
+ "user_type_id": acc_type.id,
+ "company_id": company.id,
+ }
+ )
return account
def _create_product(self):
"""Create a Product."""
# group_ids = [group.id for group in groups]
- product_ctg = self.product_ctg_model.create({
- 'name': 'test_product_ctg',
- 'property_stock_valuation_account_id': self.account_inventory.id,
- 'property_valuation': 'real_time',
- 'property_stock_account_input_categ_id': self.account_grni.id,
- 'property_stock_account_output_categ_id': self.account_cogs.id,
- })
- product = self.product_model.create({
- 'name': 'test_product',
- 'categ_id': product_ctg.id,
- 'type': 'product',
- 'standard_price': 1.0,
- 'list_price': 1.0,
- })
+ product_ctg = self.product_ctg_model.create(
+ {
+ "name": "test_product_ctg",
+ "property_stock_valuation_account_id": self.account_inventory.id,
+ "property_valuation": "real_time",
+ "property_stock_account_input_categ_id": self.account_grni.id,
+ "property_stock_account_output_categ_id": self.account_cogs.id,
+ }
+ )
+ product = self.product_model.create(
+ {
+ "name": "test_product",
+ "categ_id": product_ctg.id,
+ "type": "product",
+ "standard_price": 1.0,
+ "list_price": 1.0,
+ }
+ )
return product
def _create_sale(self, line_products):
@@ -122,47 +122,46 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
lines = []
for product, qty in line_products:
line_values = {
- 'name': product.name,
- 'product_id': product.id,
- 'product_qty': qty,
- 'product_uom': product.uom_id.id,
- 'price_unit': 500,
- 'date_planned': fields.datetime.now()
+ "name": product.name,
+ "product_id": product.id,
+ "product_qty": qty,
+ "product_uom": product.uom_id.id,
+ "price_unit": 500,
+ "date_planned": fields.datetime.now(),
}
- lines.append(
- (0, 0, line_values)
- )
- return self.sale_model.create({
- 'partner_id': self.partner1.id,
- 'order_line': lines
- })
+ lines.append((0, 0, line_values))
+ return self.sale_model.create(
+ {"partner_id": self.partner1.id, "order_line": lines}
+ )
def _get_balance(self, domain):
"""
Call read_group method and return the balance of particular account.
"""
- aml_rec = self.aml_model.read_group(domain,
- ['debit', 'credit', 'account_id'],
- ['account_id'])
+ aml_rec = self.aml_model.read_group(
+ domain, ["debit", "credit", "account_id"], ["account_id"]
+ )
if aml_rec:
- return aml_rec[0].get('debit', 0) - aml_rec[0].get('credit', 0)
+ return aml_rec[0].get("debit", 0) - aml_rec[0].get("credit", 0)
else:
return 0.0
- def _check_account_balance(self, account_id, sale_line=None,
- expected_balance=0.0):
+ def _check_account_balance(self, account_id, sale_line=None, expected_balance=0.0):
"""
Check the balance of the account
"""
- domain = [('account_id', '=', account_id)]
+ domain = [("account_id", "=", account_id)]
if sale_line:
- domain.extend([('sale_line_id', '=', sale_line.id)])
+ domain.extend([("sale_line_id", "=", sale_line.id)])
balance = self._get_balance(domain)
if sale_line:
- self.assertEqual(balance, expected_balance,
- 'Balance is not %s for sale Line %s.'
- % (str(expected_balance), sale_line.name))
+ self.assertEqual(
+ balance,
+ expected_balance,
+ "Balance is not %s for sale Line %s."
+ % (str(expected_balance), sale_line.name),
+ )
def test_sale_invoice(self):
"""Test that the po line moves from the sale order to the
@@ -176,35 +175,48 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
sale.button_confirm()
picking = sale.picking_ids[0]
picking.force_assign()
- picking.move_lines.write({'quantity_done': 1.0})
+ picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
expected_balance = 1.0
- self._check_account_balance(self.account_inventory.id,
- sale_line=po_line,
- expected_balance=expected_balance)
+ self._check_account_balance(
+ self.account_inventory.id,
+ sale_line=po_line,
+ expected_balance=expected_balance,
+ )
- invoice = self.invoice_model.create({
- 'partner_id': self.partner1.id,
- 'sale_id': sale.id,
- 'account_id': sale.partner_id.property_account_payable_id.id,
- })
+ invoice = self.invoice_model.create(
+ {
+ "partner_id": self.partner1.id,
+ "sale_id": sale.id,
+ "account_id": sale.partner_id.property_account_payable_id.id,
+ }
+ )
invoice.sale_order_change()
invoice.action_invoice_open()
for aml in invoice.move_id.line_ids:
if aml.product_id == po_line.product_id and aml.invoice_id:
- self.assertEqual(aml.sale_line_id, po_line,
- 'sale Order line has not been copied '
- 'from the invoice to the account move line.')
+ self.assertEqual(
+ aml.sale_line_id,
+ po_line,
+ "sale Order line has not been copied "
+ "from the invoice to the account move line.",
+ )
def test_name_get(self):
sale = self._create_sale([(self.product, 1)])
po_line = sale.order_line[0]
- name_get = po_line.with_context({'po_line_info': True}).name_get()
- self.assertEqual(name_get, [(po_line.id, "[%s] %s (%s)" % (
- po_line.order_id.name, po_line.name,
- po_line.order_id.state,
- ))])
+ name_get = po_line.with_context({"po_line_info": True}).name_get()
+ self.assertEqual(
+ name_get,
+ [
+ (
+ po_line.id,
+ "[%s] %s (%s)"
+ % (po_line.order_id.name, po_line.name, po_line.order_id.state,),
+ )
+ ],
+ )
name_get_no_ctx = po_line.name_get()
self.assertEqual(name_get_no_ctx, [(po_line.id, po_line.name)])
diff --git a/account_move_line_sale_info/views/account_move_view.xml b/account_move_line_sale_info/views/account_move_view.xml
index 8fa88ec9a..47541062a 100644
--- a/account_move_line_sale_info/views/account_move_view.xml
+++ b/account_move_line_sale_info/views/account_move_view.xml
@@ -1,70 +1,89 @@
-
+
-
account.move.line.form
account.move.line
-
+
-
-
+
+
-
account.move.line.tree
account.move.line
-
+
-
-
+
+
-
-
Journal Items
account.move.line
-
+
-
-
+
+
-
-
+
+
-
-
account.move.form
account.move
-
+
-
-
-
+
+
+
-
From 92a1966f871a57a7a89669dc6c3d3b7145983571 Mon Sep 17 00:00:00 2001
From: AaronHForgeFlow
Date: Mon, 3 May 2021 14:04:28 +0200
Subject: [PATCH 05/35] [MIG]account_move_line_sale_info to v13
---
account_move_line_sale_info/__manifest__.py | 10 ++-
account_move_line_sale_info/hooks.py | 25 +++---
.../migrations/13.0.1.0.0/pre-migration.py | 12 +++
.../models/__init__.py | 1 -
.../models/account_invoice.py | 39 ---------
.../models/account_move.py | 45 +++++++++-
.../models/sale_order_line.py | 12 ++-
.../models/stock_move.py | 4 +-
.../security/account_security.xml | 2 +-
.../tests/test_account_move_line_sale_info.py | 86 ++++++++++++-------
.../views/account_move_view.xml | 18 ++--
11 files changed, 149 insertions(+), 105 deletions(-)
create mode 100644 account_move_line_sale_info/migrations/13.0.1.0.0/pre-migration.py
delete mode 100644 account_move_line_sale_info/models/account_invoice.py
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index 98fc7507c..c9604302b 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -4,13 +4,17 @@
{
"name": "Account Move Line Sale Info",
"summary": "Introduces the purchase order line to the journal items",
- "version": "11.0.1.0.0",
+ "version": "13.0.1.0.0",
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
"website": "http://www.github.com/OCA/account-financial-tools",
"category": "Generic",
- "depends": ["account_move_line_stock_info", "sale"],
+ "depends": [
+ "account_move_line_stock_info",
+ "sale_stock",
+ "stock_account_prepare_anglo_saxon_out_lines_hook",
+ ],
"license": "AGPL-3",
- "data": ["security/account_security.xml", "views/account_move_view.xml",],
+ "data": ["security/account_security.xml", "views/account_move_view.xml"],
"installable": True,
"post_init_hook": "post_init_hook",
}
diff --git a/account_move_line_sale_info/hooks.py b/account_move_line_sale_info/hooks.py
index f47a472f5..46c9f0eb8 100644
--- a/account_move_line_sale_info/hooks.py
+++ b/account_move_line_sale_info/hooks.py
@@ -1,8 +1,5 @@
# Copyright 2019 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-import ast
-
-from odoo import SUPERUSER_ID, api
def post_init_hook(cr, registry):
@@ -11,7 +8,7 @@ def post_init_hook(cr, registry):
# FOR stock moves
cr.execute(
"""
- update account_move_line aml set sale_line_id = sm.sale_line_id
+ UPDATE account_move_line aml SET sale_line_id = sm.sale_line_id
FROM account_move_line aml2
INNER JOIN stock_move sm ON
aml2.stock_move_id = sm.id
@@ -21,14 +18,12 @@ def post_init_hook(cr, registry):
# FOR invoices
cr.execute(
"""
- update account_move_line aml set sale_line_id = sol.id
+ UPDATE account_move_line aml SET sale_line_id = sol.id
FROM account_move_line aml2
- INNER JOIN account_invoice ai ON
- ai.id = aml2.invoice_id
- INNER JOIN account_invoice_line ail ON
- ail.invoice_id = ai.id
+ INNER JOIN account_move am ON
+ am.id = aml2.move_id
INNER JOIN sale_order_line_invoice_rel rel ON
- rel.invoice_line_id = ail.id
+ rel.invoice_line_id = aml2.id
INNER JOIN sale_order_line sol ON
rel.order_line_id = sol.id
AND sol.product_id = aml2.product_id
@@ -40,7 +35,7 @@ def post_init_hook(cr, registry):
cr.execute(
"""
UPDATE account_move_line aml
- SET sale_id = sol.order_id
+ SET sale_order_id = sol.order_id
FROM sale_order_line AS sol
WHERE aml.sale_line_id = sol.id
RETURNING aml.move_id
@@ -53,10 +48,10 @@ def post_init_hook(cr, registry):
cr.execute(
"""
UPDATE account_move_line aml
- SET sale_id = so.id
- FROM sale_order_line so
+ SET sale_order_id = so.id
+ FROM sale_order so
LEFT JOIN account_move_line aml2
- ON aml2.sale_id = so.id
+ ON aml2.sale_order_id = so.id
WHERE aml2.move_id = aml.move_id
"""
)
@@ -66,7 +61,7 @@ def post_init_hook(cr, registry):
update account_move_line aml set sale_line_id = sol.id
FROM account_move_line aml2
INNER JOIN sale_order so ON
- so.id = aml2.sale_id
+ so.id = aml2.sale_order_id
INNER JOIN sale_order_line sol ON
so.id = sol.order_id
AND sol.product_id = aml2.product_id
diff --git a/account_move_line_sale_info/migrations/13.0.1.0.0/pre-migration.py b/account_move_line_sale_info/migrations/13.0.1.0.0/pre-migration.py
new file mode 100644
index 000000000..a3055dc5c
--- /dev/null
+++ b/account_move_line_sale_info/migrations/13.0.1.0.0/pre-migration.py
@@ -0,0 +1,12 @@
+# Copyright 2020 ForgeFlow
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+from openupgradelib import openupgrade
+
+_field_renames = [
+ ("account.move.line", "account_move_line", "sale_id", "sale_order_id",),
+]
+
+
+@openupgrade.migrate()
+def migrate(env, version):
+ openupgrade.rename_fields(env, _field_renames)
diff --git a/account_move_line_sale_info/models/__init__.py b/account_move_line_sale_info/models/__init__.py
index f4c1f16e6..c8dea955a 100644
--- a/account_move_line_sale_info/models/__init__.py
+++ b/account_move_line_sale_info/models/__init__.py
@@ -1,6 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import account_move
-from . import account_invoice
from . import sale_order_line
from . import stock_move
diff --git a/account_move_line_sale_info/models/account_invoice.py b/account_move_line_sale_info/models/account_invoice.py
deleted file mode 100644
index 73d8a555e..000000000
--- a/account_move_line_sale_info/models/account_invoice.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2020 ForgeFlow S.L.
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-
-from odoo import api, models
-
-
-class AccountInvoice(models.Model):
-
- _inherit = "account.invoice"
-
- @api.model
- def invoice_line_move_line_get(self):
- res = super(AccountInvoice, self).invoice_line_move_line_get()
-
- invoice_line_model = self.env["account.invoice.line"]
- for move_line_dict in res:
- if "invl_id" in move_line_dict:
- line = invoice_line_model.browse(move_line_dict["invl_id"])
- if line.sale_line_ids and len(line.sale_line_ids) == 1:
- move_line_dict["sale_line_id"] = line.sale_line_ids[0].id
- return res
-
- @api.model
- def line_get_convert(self, line, part):
- res = super(AccountInvoice, self).line_get_convert(line, part)
- if line.get("sale_line_id", False):
- res["sale_line_id"] = line.get("sale_line_id")
- return res
-
- @api.model
- def _anglo_saxon_sale_move_lines(self, i_line):
- """
- We need to add the sale_line to those entries too
- """
- res = super()._anglo_saxon_sale_move_lines(i_line)
- for aml in res:
- if i_line.sale_line_ids and len(i_line.sale_line_ids) == 1:
- aml["sale_line_id"] = i_line.sale_line_ids[0].id
- return res
diff --git a/account_move_line_sale_info/models/account_move.py b/account_move_line_sale_info/models/account_move.py
index d84d53cc0..6e1bff1b1 100644
--- a/account_move_line_sale_info/models/account_move.py
+++ b/account_move_line_sale_info/models/account_move.py
@@ -4,6 +4,49 @@
from odoo import fields, models
+class AccountMove(models.Model):
+
+ _inherit = "account.move"
+
+ def _prepare_interim_account_line_vals(self, line, move, debit_interim_account):
+ res = super()._prepare_interim_account_line_vals(
+ line, move, debit_interim_account
+ )
+ if (
+ not res.get("move_id", False)
+ or not res.get("product_id", False)
+ or not res.get("quantity", False)
+ ):
+ return res
+ am = self.env["account.move"].browse(res["move_id"])
+ sale_line_id = am.invoice_line_ids.filtered(
+ lambda il: il.product_id.id == res["product_id"]
+ and il.quantity == res["quantity"]
+ ).mapped("sale_line_id")
+ if sale_line_id and len(sale_line_id) == 1:
+ res["sale_line_id"] = sale_line_id.id
+ return res
+
+ def _prepare_expense_account_line_vals(self, line, move, debit_interim_account):
+ res = super()._prepare_expense_account_line_vals(
+ line, move, debit_interim_account
+ )
+ if (
+ not res.get("move_id", False)
+ or not res.get("product_id", False)
+ or not res.get("quantity", False)
+ ):
+ return res
+ am = self.env["account.move"].browse(res["move_id"])
+ sale_line_id = am.invoice_line_ids.filtered(
+ lambda il: il.product_id.id == res["product_id"]
+ and il.quantity == res["quantity"]
+ ).mapped("sale_line_id")
+ if sale_line_id and len(sale_line_id) == 1:
+ res["sale_line_id"] = sale_line_id.id
+ return res
+
+
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
@@ -15,7 +58,7 @@ class AccountMoveLine(models.Model):
index=True,
)
- sale_id = fields.Many2one(
+ sale_order_id = fields.Many2one(
comodel_name="sale.order",
related="sale_line_id.order_id",
string="Sales Order",
diff --git a/account_move_line_sale_info/models/sale_order_line.py b/account_move_line_sale_info/models/sale_order_line.py
index fc103cc44..75f7eeee9 100644
--- a/account_move_line_sale_info/models/sale_order_line.py
+++ b/account_move_line_sale_info/models/sale_order_line.py
@@ -1,19 +1,25 @@
# Copyright 2020 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from odoo import api, models
+from odoo import models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
- @api.multi
def name_get(self):
result = []
orig_name = dict(super(SaleOrderLine, self).name_get())
for line in self:
name = orig_name[line.id]
if self.env.context.get("so_line_info", False):
- name = "[{}] {} ({})".format(line.order_id.name, name, line.order_id.state)
+ name = "[{}] {} - ({})".format(
+ line.order_id.name, line.product_id.name, line.order_id.state
+ )
result.append((line.id, name))
return result
+
+ def _prepare_invoice_line(self):
+ res = super(SaleOrderLine, self)._prepare_invoice_line()
+ res["sale_line_id"] = self.id
+ return res
diff --git a/account_move_line_sale_info/models/stock_move.py b/account_move_line_sale_info/models/stock_move.py
index 07b1bb0b7..4f522e110 100644
--- a/account_move_line_sale_info/models/stock_move.py
+++ b/account_move_line_sale_info/models/stock_move.py
@@ -8,10 +8,10 @@ class StockMove(models.Model):
@api.model
def _prepare_account_move_line(
- self, qty, cost, credit_account_id, debit_account_id
+ self, qty, cost, credit_account_id, debit_account_id, description
):
res = super(StockMove, self)._prepare_account_move_line(
- qty, cost, credit_account_id, debit_account_id
+ qty, cost, credit_account_id, debit_account_id, description
)
for line in res:
line[2]["sale_line_id"] = self.sale_line_id.id
diff --git a/account_move_line_sale_info/security/account_security.xml b/account_move_line_sale_info/security/account_security.xml
index bd3f7e6d5..ab6f92cc5 100644
--- a/account_move_line_sale_info/security/account_security.xml
+++ b/account_move_line_sale_info/security/account_security.xml
@@ -3,6 +3,6 @@
Sale info in Journal Items
-
+
diff --git a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
index 29f62d448..7d14e8cef 100644
--- a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
+++ b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
@@ -1,6 +1,5 @@
# Copyright 2020 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from odoo import fields
from odoo.tests import common
@@ -9,8 +8,6 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
super(TestAccountMoveLineSaleInfo, self).setUp()
self.sale_model = self.env["sale.order"]
self.sale_line_model = self.env["sale.order.line"]
- self.invoice_model = self.env["account.invoice"]
- self.invoice_line_model = self.env["account.invoice.line"]
self.product_model = self.env["product.product"]
self.product_ctg_model = self.env["product.category"]
self.acc_type_model = self.env["account.account.type"]
@@ -58,6 +55,15 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
self.account_manager = self._create_user(
"account_manager", [self.group_account_manager], self.company
)
+ self.JournalObj = self.env["account.journal"]
+ self.journal_sale = self.JournalObj.create(
+ {
+ "name": "Test journal sale",
+ "code": "TST-JRNL-S",
+ "type": "sale",
+ "company_id": self.company.id,
+ }
+ )
def _create_user(self, login, groups, company):
""" Create a user."""
@@ -75,8 +81,10 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
)
return user.id
- def _create_account_type(self, name, type):
- acc_type = self.acc_type_model.create({"name": name, "type": type})
+ def _create_account_type(self, name, atype):
+ acc_type = self.acc_type_model.create(
+ {"name": name, "type": atype, "internal_group": name}
+ )
return acc_type
def _create_account(self, acc_type, name, code, company):
@@ -124,10 +132,9 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
line_values = {
"name": product.name,
"product_id": product.id,
- "product_qty": qty,
+ "product_uom_qty": qty,
"product_uom": product.uom_id.id,
"price_unit": 500,
- "date_planned": fields.datetime.now(),
}
lines.append((0, 0, line_values))
return self.sale_model.create(
@@ -168,55 +175,70 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
account move line and to the invoice line.
"""
sale = self._create_sale([(self.product, 1)])
- po_line = False
+ so_line = False
for line in sale.order_line:
- po_line = line
+ so_line = line
break
- sale.button_confirm()
+ sale.action_confirm()
picking = sale.picking_ids[0]
- picking.force_assign()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
- expected_balance = 1.0
+ expected_balance = -1.0
self._check_account_balance(
self.account_inventory.id,
- sale_line=po_line,
+ sale_line=so_line,
expected_balance=expected_balance,
)
-
- invoice = self.invoice_model.create(
- {
- "partner_id": self.partner1.id,
- "sale_id": sale.id,
- "account_id": sale.partner_id.property_account_payable_id.id,
- }
+ self.context = {
+ "active_model": "sale.order",
+ "active_ids": [sale.id],
+ "active_id": sale.id,
+ "default_journal_id": self.journal_sale.id,
+ }
+ payment = (
+ self.env["sale.advance.payment.inv"]
+ .with_context(self.context)
+ .create({"advance_payment_method": "delivered"})
)
- invoice.sale_order_change()
- invoice.action_invoice_open()
+ payment.create_invoices()
+ invoice = sale.invoice_ids[0]
+ invoice.post()
- for aml in invoice.move_id.line_ids:
- if aml.product_id == po_line.product_id and aml.invoice_id:
+ for aml in invoice.line_ids:
+ if aml.product_id == so_line.product_id and aml.move_id:
self.assertEqual(
aml.sale_line_id,
- po_line,
+ so_line,
"sale Order line has not been copied "
"from the invoice to the account move line.",
)
def test_name_get(self):
sale = self._create_sale([(self.product, 1)])
- po_line = sale.order_line[0]
- name_get = po_line.with_context({"po_line_info": True}).name_get()
+ so_line = sale.order_line[0]
+ name_get = so_line.with_context({"so_line_info": True}).name_get()
self.assertEqual(
name_get,
[
(
- po_line.id,
- "[%s] %s (%s)"
- % (po_line.order_id.name, po_line.name, po_line.order_id.state,),
+ so_line.id,
+ "[%s] %s - (%s)"
+ % (
+ so_line.order_id.name,
+ so_line.product_id.name,
+ so_line.order_id.state,
+ ),
+ )
+ ],
+ )
+ name_get_no_ctx = so_line.with_context({}).name_get()
+ self.assertEqual(
+ name_get_no_ctx,
+ [
+ (
+ so_line.id,
+ "{} - {}".format(so_line.order_id.name, so_line.product_id.name),
)
],
)
- name_get_no_ctx = po_line.name_get()
- self.assertEqual(name_get_no_ctx, [(po_line.id, po_line.name)])
diff --git a/account_move_line_sale_info/views/account_move_view.xml b/account_move_line_sale_info/views/account_move_view.xml
index 47541062a..984543f79 100644
--- a/account_move_line_sale_info/views/account_move_view.xml
+++ b/account_move_line_sale_info/views/account_move_view.xml
@@ -7,7 +7,7 @@
-
+
-
+
@@ -80,7 +82,7 @@
groups="account_move_line_sale_info.group_account_move_sale_info"
/>
From 0a74fe78da8bd79784501163f46aeedd1685ad42 Mon Sep 17 00:00:00 2001
From: oca-travis
Date: Thu, 10 Jun 2021 16:24:54 +0000
Subject: [PATCH 06/35] [UPD] Update account_move_line_sale_info.pot
---
.../i18n/account_move_line_sale_info.pot | 59 +++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 account_move_line_sale_info/i18n/account_move_line_sale_info.pot
diff --git a/account_move_line_sale_info/i18n/account_move_line_sale_info.pot b/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
new file mode 100644
index 000000000..a768fbe16
--- /dev/null
+++ b/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
@@ -0,0 +1,59 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * account_move_line_sale_info
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 13.0\n"
+"Report-Msgid-Bugs-To: \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: account_move_line_sale_info
+#: model:ir.model,name:account_move_line_sale_info.model_account_move
+msgid "Journal Entries"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:ir.model,name:account_move_line_sale_info.model_account_move_line
+msgid "Journal Item"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:ir.model.fields,field_description:account_move_line_sale_info.field_account_move_line__sale_line_id
+msgid "Sale Order Line"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:res.groups,name:account_move_line_sale_info.group_account_move_sale_info
+msgid "Sale info in Journal Items"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:ir.model.fields,field_description:account_move_line_sale_info.field_account_move_line__sale_order_id
+msgid "Sales Order"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:ir.model,name:account_move_line_sale_info.model_sale_order_line
+msgid "Sales Order Line"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:ir.model,name:account_move_line_sale_info.model_stock_move
+msgid "Stock Move"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model_terms:ir.ui.view,arch_db:account_move_line_sale_info.view_account_move_line_filter
+msgid "sale Order"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model_terms:ir.ui.view,arch_db:account_move_line_sale_info.view_account_move_line_filter
+msgid "sale Order Line"
+msgstr ""
From b537d75ca049220236beddf15be5369b0e74e362 Mon Sep 17 00:00:00 2001
From: AaronHForgeFlow
Date: Tue, 10 Aug 2021 10:21:16 +0200
Subject: [PATCH 07/35] [IMP] account_move_line_sale_info optional fields in
tree view
---
account_move_line_sale_info/views/account_move_view.xml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/account_move_line_sale_info/views/account_move_view.xml b/account_move_line_sale_info/views/account_move_view.xml
index 984543f79..260b3783d 100644
--- a/account_move_line_sale_info/views/account_move_view.xml
+++ b/account_move_line_sale_info/views/account_move_view.xml
@@ -25,10 +25,12 @@
@@ -52,14 +54,14 @@
Date: Tue, 17 Aug 2021 10:54:42 +0000
Subject: [PATCH 08/35] [UPD] Update account_move_line_sale_info.pot
---
.../i18n/account_move_line_sale_info.pot | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/account_move_line_sale_info/i18n/account_move_line_sale_info.pot b/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
index a768fbe16..2136039ef 100644
--- a/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
+++ b/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
@@ -23,8 +23,14 @@ msgstr ""
msgid "Journal Item"
msgstr ""
+#. module: account_move_line_sale_info
+#: model_terms:ir.ui.view,arch_db:account_move_line_sale_info.view_account_move_line_filter
+msgid "Sale Order"
+msgstr ""
+
#. module: account_move_line_sale_info
#: model:ir.model.fields,field_description:account_move_line_sale_info.field_account_move_line__sale_line_id
+#: model_terms:ir.ui.view,arch_db:account_move_line_sale_info.view_account_move_line_filter
msgid "Sale Order Line"
msgstr ""
@@ -47,13 +53,3 @@ msgstr ""
#: model:ir.model,name:account_move_line_sale_info.model_stock_move
msgid "Stock Move"
msgstr ""
-
-#. module: account_move_line_sale_info
-#: model_terms:ir.ui.view,arch_db:account_move_line_sale_info.view_account_move_line_filter
-msgid "sale Order"
-msgstr ""
-
-#. module: account_move_line_sale_info
-#: model_terms:ir.ui.view,arch_db:account_move_line_sale_info.view_account_move_line_filter
-msgid "sale Order Line"
-msgstr ""
From 57f02e8f638df46eba4757fcbe45739ab79e2158 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Tue, 17 Aug 2021 11:19:29 +0000
Subject: [PATCH 09/35] account_move_line_sale_info 13.0.1.0.1
---
account_move_line_sale_info/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index c9604302b..ccd600b36 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Account Move Line Sale Info",
"summary": "Introduces the purchase order line to the journal items",
- "version": "13.0.1.0.0",
+ "version": "13.0.1.0.1",
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
"website": "http://www.github.com/OCA/account-financial-tools",
"category": "Generic",
From 029c57c6e30b481db36dc271b060b410ed81103a Mon Sep 17 00:00:00 2001
From: AaronHForgeFlow
Date: Tue, 5 Oct 2021 09:41:58 +0200
Subject: [PATCH 10/35] [FIX] account_move_line_sale_info: do not copy sale
references
---
account_move_line_sale_info/models/account_move.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/account_move_line_sale_info/models/account_move.py b/account_move_line_sale_info/models/account_move.py
index 6e1bff1b1..27710ab78 100644
--- a/account_move_line_sale_info/models/account_move.py
+++ b/account_move_line_sale_info/models/account_move.py
@@ -56,6 +56,7 @@ class AccountMoveLine(models.Model):
string="Sale Order Line",
ondelete="set null",
index=True,
+ copy=False,
)
sale_order_id = fields.Many2one(
@@ -65,4 +66,5 @@ class AccountMoveLine(models.Model):
ondelete="set null",
store=True,
index=True,
+ copy=False,
)
From 057b30d1ebf1630e7559a10d9128c0d7a4cd0576 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Wed, 6 Oct 2021 07:17:04 +0000
Subject: [PATCH 11/35] account_move_line_sale_info 13.0.1.0.2
---
account_move_line_sale_info/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index ccd600b36..d5cadd332 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Account Move Line Sale Info",
"summary": "Introduces the purchase order line to the journal items",
- "version": "13.0.1.0.1",
+ "version": "13.0.1.0.2",
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
"website": "http://www.github.com/OCA/account-financial-tools",
"category": "Generic",
From fb6beeda59805126466c6c52ab750be9012f31bd Mon Sep 17 00:00:00 2001
From: AaronHForgeFlow
Date: Tue, 26 Oct 2021 13:27:46 +0200
Subject: [PATCH 12/35] [IMP] account_move_sale_info: make sale fields optional
in journal entries
---
account_move_line_sale_info/views/account_move_view.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/account_move_line_sale_info/views/account_move_view.xml b/account_move_line_sale_info/views/account_move_view.xml
index 260b3783d..93a240070 100644
--- a/account_move_line_sale_info/views/account_move_view.xml
+++ b/account_move_line_sale_info/views/account_move_view.xml
@@ -81,10 +81,12 @@
From 78e085c1b0e15e95f7876f949b4e68a7fbca820f Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Thu, 28 Oct 2021 09:17:04 +0000
Subject: [PATCH 13/35] account_move_line_sale_info 13.0.1.0.3
---
account_move_line_sale_info/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index d5cadd332..3c07ce3b0 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Account Move Line Sale Info",
"summary": "Introduces the purchase order line to the journal items",
- "version": "13.0.1.0.2",
+ "version": "13.0.1.0.3",
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
"website": "http://www.github.com/OCA/account-financial-tools",
"category": "Generic",
From 691a0b149d947b375fce9b793475edd6f8921b94 Mon Sep 17 00:00:00 2001
From: Joan Mateu Jordi
Date: Tue, 9 Nov 2021 14:38:50 +0100
Subject: [PATCH 14/35] [15.0][MIG] account_move_line_sale_info: Migration to
15.0
---
account_move_line_sale_info/README.rst | 1 +
account_move_line_sale_info/__manifest__.py | 5 +-
account_move_line_sale_info/hooks.py | 2 +-
.../migrations/13.0.1.0.0/pre-migration.py | 12 -----
.../models/account_move.py | 53 ++++++-------------
.../models/sale_order_line.py | 4 +-
.../readme/CONFIGURE.rst | 0
.../readme/CONTRIBUTORS.rst | 1 +
.../readme/DESCRIPTION.rst | 4 ++
account_move_line_sale_info/readme/USAGE.rst | 7 +++
.../tests/test_account_move_line_sale_info.py | 12 ++---
11 files changed, 40 insertions(+), 61 deletions(-)
delete mode 100644 account_move_line_sale_info/migrations/13.0.1.0.0/pre-migration.py
create mode 100644 account_move_line_sale_info/readme/CONFIGURE.rst
create mode 100644 account_move_line_sale_info/readme/CONTRIBUTORS.rst
create mode 100644 account_move_line_sale_info/readme/DESCRIPTION.rst
create mode 100644 account_move_line_sale_info/readme/USAGE.rst
diff --git a/account_move_line_sale_info/README.rst b/account_move_line_sale_info/README.rst
index bd79bd9d8..649642037 100644
--- a/account_move_line_sale_info/README.rst
+++ b/account_move_line_sale_info/README.rst
@@ -44,6 +44,7 @@ Images
* Odoo Community Association: `Icon `_.
+
Contributors
------------
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index 3c07ce3b0..a30d046c9 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -4,14 +4,13 @@
{
"name": "Account Move Line Sale Info",
"summary": "Introduces the purchase order line to the journal items",
- "version": "13.0.1.0.3",
+ "version": "15.0.1.0.0",
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
- "website": "http://www.github.com/OCA/account-financial-tools",
+ "website": "https://github.com/OCA/account-financial-tools",
"category": "Generic",
"depends": [
"account_move_line_stock_info",
"sale_stock",
- "stock_account_prepare_anglo_saxon_out_lines_hook",
],
"license": "AGPL-3",
"data": ["security/account_security.xml", "views/account_move_view.xml"],
diff --git a/account_move_line_sale_info/hooks.py b/account_move_line_sale_info/hooks.py
index 46c9f0eb8..cd6be3739 100644
--- a/account_move_line_sale_info/hooks.py
+++ b/account_move_line_sale_info/hooks.py
@@ -4,7 +4,7 @@
def post_init_hook(cr, registry):
- """ INIT sale references in acount move line """
+ """INIT sale references in account move line"""
# FOR stock moves
cr.execute(
"""
diff --git a/account_move_line_sale_info/migrations/13.0.1.0.0/pre-migration.py b/account_move_line_sale_info/migrations/13.0.1.0.0/pre-migration.py
deleted file mode 100644
index a3055dc5c..000000000
--- a/account_move_line_sale_info/migrations/13.0.1.0.0/pre-migration.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2020 ForgeFlow
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from openupgradelib import openupgrade
-
-_field_renames = [
- ("account.move.line", "account_move_line", "sale_id", "sale_order_id",),
-]
-
-
-@openupgrade.migrate()
-def migrate(env, version):
- openupgrade.rename_fields(env, _field_renames)
diff --git a/account_move_line_sale_info/models/account_move.py b/account_move_line_sale_info/models/account_move.py
index 27710ab78..6e8cf8146 100644
--- a/account_move_line_sale_info/models/account_move.py
+++ b/account_move_line_sale_info/models/account_move.py
@@ -5,45 +5,24 @@ from odoo import fields, models
class AccountMove(models.Model):
-
_inherit = "account.move"
- def _prepare_interim_account_line_vals(self, line, move, debit_interim_account):
- res = super()._prepare_interim_account_line_vals(
- line, move, debit_interim_account
- )
- if (
- not res.get("move_id", False)
- or not res.get("product_id", False)
- or not res.get("quantity", False)
- ):
- return res
- am = self.env["account.move"].browse(res["move_id"])
- sale_line_id = am.invoice_line_ids.filtered(
- lambda il: il.product_id.id == res["product_id"]
- and il.quantity == res["quantity"]
- ).mapped("sale_line_id")
- if sale_line_id and len(sale_line_id) == 1:
- res["sale_line_id"] = sale_line_id.id
- return res
-
- def _prepare_expense_account_line_vals(self, line, move, debit_interim_account):
- res = super()._prepare_expense_account_line_vals(
- line, move, debit_interim_account
- )
- if (
- not res.get("move_id", False)
- or not res.get("product_id", False)
- or not res.get("quantity", False)
- ):
- return res
- am = self.env["account.move"].browse(res["move_id"])
- sale_line_id = am.invoice_line_ids.filtered(
- lambda il: il.product_id.id == res["product_id"]
- and il.quantity == res["quantity"]
- ).mapped("sale_line_id")
- if sale_line_id and len(sale_line_id) == 1:
- res["sale_line_id"] = sale_line_id.id
+ def _stock_account_prepare_anglo_saxon_out_lines_vals(self):
+ res = super()._stock_account_prepare_anglo_saxon_out_lines_vals()
+ for i, vals in enumerate(res):
+ if (
+ not vals.get("move_id", False)
+ or not vals.get("product_id", False)
+ or not vals.get("quantity", False)
+ ):
+ continue
+ am = self.env["account.move"].browse(vals["move_id"])
+ sale_line_id = am.invoice_line_ids.filtered(
+ lambda il: il.product_id.id == vals["product_id"]
+ and il.quantity == vals["quantity"]
+ ).mapped("sale_line_id")
+ if sale_line_id and len(sale_line_id) == 1:
+ res[i]["sale_line_id"] = sale_line_id.id
return res
diff --git a/account_move_line_sale_info/models/sale_order_line.py b/account_move_line_sale_info/models/sale_order_line.py
index 75f7eeee9..a46eeac9b 100644
--- a/account_move_line_sale_info/models/sale_order_line.py
+++ b/account_move_line_sale_info/models/sale_order_line.py
@@ -19,7 +19,7 @@ class SaleOrderLine(models.Model):
result.append((line.id, name))
return result
- def _prepare_invoice_line(self):
- res = super(SaleOrderLine, self)._prepare_invoice_line()
+ def _prepare_invoice_line(self, **optional_values):
+ res = super()._prepare_invoice_line(**optional_values)
res["sale_line_id"] = self.id
return res
diff --git a/account_move_line_sale_info/readme/CONFIGURE.rst b/account_move_line_sale_info/readme/CONFIGURE.rst
new file mode 100644
index 000000000..e69de29bb
diff --git a/account_move_line_sale_info/readme/CONTRIBUTORS.rst b/account_move_line_sale_info/readme/CONTRIBUTORS.rst
new file mode 100644
index 000000000..2e524967e
--- /dev/null
+++ b/account_move_line_sale_info/readme/CONTRIBUTORS.rst
@@ -0,0 +1 @@
+* Aaron Henriquez
diff --git a/account_move_line_sale_info/readme/DESCRIPTION.rst b/account_move_line_sale_info/readme/DESCRIPTION.rst
new file mode 100644
index 000000000..9d1624060
--- /dev/null
+++ b/account_move_line_sale_info/readme/DESCRIPTION.rst
@@ -0,0 +1,4 @@
+This module will add the sale order line to journal items.
+
+The ultimate goal is to establish the purchase order line as one of the key
+fields to reconcile the Goods Delivered Not Invoiced accrual account.
diff --git a/account_move_line_sale_info/readme/USAGE.rst b/account_move_line_sale_info/readme/USAGE.rst
new file mode 100644
index 000000000..d75919ab3
--- /dev/null
+++ b/account_move_line_sale_info/readme/USAGE.rst
@@ -0,0 +1,7 @@
+The sale order line will be automatically copied to the journal items.
+
+* When a supplier invoice is created referencing sales orders, the
+ sale order line will be copied to the corresponding journal item.
+
+* When a stock move is validated and generates a journal entry, the sale
+ order line is copied to the account move line.
diff --git a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
index 7d14e8cef..f5df5d89d 100644
--- a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
+++ b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
@@ -66,9 +66,9 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
)
def _create_user(self, login, groups, company):
- """ Create a user."""
+ """Create a user."""
group_ids = [group.id for group in groups]
- user = self.res_users_model.with_context({"no_reset_password": True}).create(
+ user = self.res_users_model.with_context(**{"no_reset_password": True}).create(
{
"name": "Test User",
"login": login,
@@ -123,7 +123,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
return product
def _create_sale(self, line_products):
- """ Create a sale order.
+ """Create a sale order.
``line_products`` is a list of tuple [(product, qty)]
"""
@@ -198,7 +198,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
}
payment = (
self.env["sale.advance.payment.inv"]
- .with_context(self.context)
+ .with_context(**self.context)
.create({"advance_payment_method": "delivered"})
)
payment.create_invoices()
@@ -217,7 +217,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
def test_name_get(self):
sale = self._create_sale([(self.product, 1)])
so_line = sale.order_line[0]
- name_get = so_line.with_context({"so_line_info": True}).name_get()
+ name_get = so_line.with_context(**{"so_line_info": True}).name_get()
self.assertEqual(
name_get,
[
@@ -232,7 +232,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
)
],
)
- name_get_no_ctx = so_line.with_context({}).name_get()
+ name_get_no_ctx = so_line.with_context(**{}).name_get()
self.assertEqual(
name_get_no_ctx,
[
From 60184ff5a0e46a88656574b9d0a50d7dd652f47c Mon Sep 17 00:00:00 2001
From: oca-ci
Date: Thu, 18 Nov 2021 16:25:20 +0000
Subject: [PATCH 15/35] [UPD] Update account_move_line_sale_info.pot
---
.../i18n/account_move_line_sale_info.pot | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/account_move_line_sale_info/i18n/account_move_line_sale_info.pot b/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
index 2136039ef..3b7599574 100644
--- a/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
+++ b/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 13.0\n"
+"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -15,7 +15,7 @@ msgstr ""
#. module: account_move_line_sale_info
#: model:ir.model,name:account_move_line_sale_info.model_account_move
-msgid "Journal Entries"
+msgid "Journal Entry"
msgstr ""
#. module: account_move_line_sale_info
From 773eb96fb3576b5c7d30b589ef957afe2b4976a5 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Thu, 18 Nov 2021 16:28:46 +0000
Subject: [PATCH 16/35] [UPD] README.rst
---
account_move_line_sale_info/README.rst | 65 ++-
.../static/description/index.html | 432 ++++++++++++++++++
2 files changed, 475 insertions(+), 22 deletions(-)
create mode 100644 account_move_line_sale_info/static/description/index.html
diff --git a/account_move_line_sale_info/README.rst b/account_move_line_sale_info/README.rst
index 649642037..ffc696039 100644
--- a/account_move_line_sale_info/README.rst
+++ b/account_move_line_sale_info/README.rst
@@ -1,16 +1,39 @@
-.. image:: https://img.shields.io/badge/license-AGPLv3-blue.svg
- :target: https://www.gnu.org/licenses/agpl.html
- :alt: License: AGPL-3
-
===========================
Account Move Line Sale Info
===========================
+.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! This file is generated by oca-gen-addon-readme !!
+ !! changes will be overwritten. !!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
+ :target: https://odoo-community.org/page/development-status
+ :alt: Beta
+.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+ :alt: License: AGPL-3
+.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
+ :target: https://github.com/OCA/account-financial-tools/tree/15.0/account_move_line_sale_info
+ :alt: OCA/account-financial-tools
+.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
+ :target: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_move_line_sale_info
+ :alt: Translate me on Weblate
+.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
+ :target: https://runbot.odoo-community.org/runbot/92/15.0
+ :alt: Try me on Runbot
+
+|badge1| |badge2| |badge3| |badge4| |badge5|
+
This module will add the sale order line to journal items.
The ultimate goal is to establish the purchase order line as one of the key
fields to reconcile the Goods Delivered Not Invoiced accrual account.
+**Table of contents**
+
+.. contents::
+ :local:
Usage
=====
@@ -23,44 +46,42 @@ The sale order line will be automatically copied to the journal items.
* When a stock move is validated and generates a journal entry, the sale
order line is copied to the account move line.
-.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
- :alt: Try me on Runbot
- :target: https://runbot.odoo-community.org/runbot/92/11.0
-
Bug Tracker
===========
-Bugs are tracked on `GitHub Issues
-`_. In case of trouble, please
-check there if your issue has already been reported. If you spotted it first,
-help us smashing it by providing a detailed and welcomed feedback.
+Bugs are tracked on `GitHub Issues `_.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+`feedback `_.
+Do not contact contributors directly about support or help with technical issues.
Credits
=======
-Images
-------
-
-* Odoo Community Association: `Icon `_.
+Authors
+~~~~~~~
+* ForgeFlow S.L.
Contributors
-------------
+~~~~~~~~~~~~
* Aaron Henriquez
-Maintainer
-----------
+Maintainers
+~~~~~~~~~~~
+
+This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
-This module is maintained by the OCA.
-
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-To contribute to this module, please visit https://odoo-community.org.
+This module is part of the `OCA/account-financial-tools `_ project on GitHub.
+
+You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/account_move_line_sale_info/static/description/index.html b/account_move_line_sale_info/static/description/index.html
new file mode 100644
index 000000000..5d2370c9a
--- /dev/null
+++ b/account_move_line_sale_info/static/description/index.html
@@ -0,0 +1,432 @@
+
+
+
+
+
+
+Account Move Line Sale Info
+
+
+
+
+
Account Move Line Sale Info
+
+
+

+
This module will add the sale order line to journal items.
+
The ultimate goal is to establish the purchase order line as one of the key
+fields to reconcile the Goods Delivered Not Invoiced accrual account.
+
Table of contents
+
+
+
+
The sale order line will be automatically copied to the journal items.
+
+- When a supplier invoice is created referencing sales orders, the
+sale order line will be copied to the corresponding journal item.
+- When a stock move is validated and generates a journal entry, the sale
+order line is copied to the account move line.
+
+
+
+
+
Bugs are tracked on GitHub Issues.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+feedback.
+
Do not contact contributors directly about support or help with technical issues.
+
+
+
+
+
+
+
+
This module is maintained by the OCA.
+

+
OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
This module is part of the OCA/account-financial-tools project on GitHub.
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
+
+
+
+
+
From 2c179d97a4037c22d0069795a0873e07df25a02d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miquel=20Ra=C3=AFch?=
Date: Thu, 16 Dec 2021 14:55:32 +0100
Subject: [PATCH 17/35] [FIX] call correct method _post() to post invoices
---
.../tests/test_account_move_line_sale_info.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
index f5df5d89d..000310c51 100644
--- a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
+++ b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
@@ -203,7 +203,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
)
payment.create_invoices()
invoice = sale.invoice_ids[0]
- invoice.post()
+ invoice._post()
for aml in invoice.line_ids:
if aml.product_id == so_line.product_id and aml.move_id:
From 51cc1c5529343ef68a655ac577f8a3fe52fa2d88 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Mon, 10 Jan 2022 09:36:21 +0000
Subject: [PATCH 18/35] account_move_line_sale_info 15.0.1.0.1
---
account_move_line_sale_info/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index a30d046c9..da7f0341c 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Account Move Line Sale Info",
"summary": "Introduces the purchase order line to the journal items",
- "version": "15.0.1.0.0",
+ "version": "15.0.1.0.1",
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"category": "Generic",
From 5087eca7ae37beb8feb022affef301132ca397c3 Mon Sep 17 00:00:00 2001
From: Ignacio Buioli
Date: Mon, 23 May 2022 03:15:53 +0000
Subject: [PATCH 19/35] Added translation using Weblate (Spanish (Argentina))
---
account_move_line_sale_info/i18n/es_AR.po | 56 +++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 account_move_line_sale_info/i18n/es_AR.po
diff --git a/account_move_line_sale_info/i18n/es_AR.po b/account_move_line_sale_info/i18n/es_AR.po
new file mode 100644
index 000000000..1654ffa35
--- /dev/null
+++ b/account_move_line_sale_info/i18n/es_AR.po
@@ -0,0 +1,56 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * account_move_line_sale_info
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 15.0\n"
+"Report-Msgid-Bugs-To: \n"
+"Last-Translator: Automatically generated\n"
+"Language-Team: none\n"
+"Language: es_AR\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+
+#. module: account_move_line_sale_info
+#: model:ir.model,name:account_move_line_sale_info.model_account_move
+msgid "Journal Entry"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:ir.model,name:account_move_line_sale_info.model_account_move_line
+msgid "Journal Item"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model_terms:ir.ui.view,arch_db:account_move_line_sale_info.view_account_move_line_filter
+msgid "Sale Order"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:ir.model.fields,field_description:account_move_line_sale_info.field_account_move_line__sale_line_id
+#: model_terms:ir.ui.view,arch_db:account_move_line_sale_info.view_account_move_line_filter
+msgid "Sale Order Line"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:res.groups,name:account_move_line_sale_info.group_account_move_sale_info
+msgid "Sale info in Journal Items"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:ir.model.fields,field_description:account_move_line_sale_info.field_account_move_line__sale_order_id
+msgid "Sales Order"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:ir.model,name:account_move_line_sale_info.model_sale_order_line
+msgid "Sales Order Line"
+msgstr ""
+
+#. module: account_move_line_sale_info
+#: model:ir.model,name:account_move_line_sale_info.model_stock_move
+msgid "Stock Move"
+msgstr ""
From 8d9aa0526b81d42c027a0d433bcfe943c5704b12 Mon Sep 17 00:00:00 2001
From: Ignacio Buioli
Date: Mon, 23 May 2022 03:18:21 +0000
Subject: [PATCH 20/35] Translated using Weblate (Spanish (Argentina))
Currently translated at 100.0% (8 of 8 strings)
Translation: account-financial-tools-15.0/account-financial-tools-15.0-account_move_line_sale_info
Translate-URL: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_move_line_sale_info/es_AR/
---
account_move_line_sale_info/i18n/es_AR.po | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/account_move_line_sale_info/i18n/es_AR.po b/account_move_line_sale_info/i18n/es_AR.po
index 1654ffa35..8be0dc26d 100644
--- a/account_move_line_sale_info/i18n/es_AR.po
+++ b/account_move_line_sale_info/i18n/es_AR.po
@@ -6,51 +6,53 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: Automatically generated\n"
+"PO-Revision-Date: 2022-05-23 06:05+0000\n"
+"Last-Translator: Ignacio Buioli \n"
"Language-Team: none\n"
"Language: es_AR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"X-Generator: Weblate 4.3.2\n"
#. module: account_move_line_sale_info
#: model:ir.model,name:account_move_line_sale_info.model_account_move
msgid "Journal Entry"
-msgstr ""
+msgstr "Asiento Contable"
#. module: account_move_line_sale_info
#: model:ir.model,name:account_move_line_sale_info.model_account_move_line
msgid "Journal Item"
-msgstr ""
+msgstr "Apunte Contable"
#. module: account_move_line_sale_info
#: model_terms:ir.ui.view,arch_db:account_move_line_sale_info.view_account_move_line_filter
msgid "Sale Order"
-msgstr ""
+msgstr "Pedido de Venta"
#. module: account_move_line_sale_info
#: model:ir.model.fields,field_description:account_move_line_sale_info.field_account_move_line__sale_line_id
#: model_terms:ir.ui.view,arch_db:account_move_line_sale_info.view_account_move_line_filter
msgid "Sale Order Line"
-msgstr ""
+msgstr "Línea de Pedido de Venta"
#. module: account_move_line_sale_info
#: model:res.groups,name:account_move_line_sale_info.group_account_move_sale_info
msgid "Sale info in Journal Items"
-msgstr ""
+msgstr "Información de Venta de los Apuntes Contables"
#. module: account_move_line_sale_info
#: model:ir.model.fields,field_description:account_move_line_sale_info.field_account_move_line__sale_order_id
msgid "Sales Order"
-msgstr ""
+msgstr "Pedido de Venta"
#. module: account_move_line_sale_info
#: model:ir.model,name:account_move_line_sale_info.model_sale_order_line
msgid "Sales Order Line"
-msgstr ""
+msgstr "Línea de Pedido de Venta"
#. module: account_move_line_sale_info
#: model:ir.model,name:account_move_line_sale_info.model_stock_move
msgid "Stock Move"
-msgstr ""
+msgstr "Movimiento de Inventario"
From b050f0433441622802e3d7dbee3e87c2d364dd05 Mon Sep 17 00:00:00 2001
From: AaronHForgeFlow
Date: Thu, 1 Dec 2022 11:09:00 +0100
Subject: [PATCH 21/35] [13.0][FIX] account_move_line_sale_info: add the sale
line information to credit notes
---
.../models/account_move.py | 6 +++
.../tests/test_account_move_line_sale_info.py | 39 ++++++++++++++++++-
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/account_move_line_sale_info/models/account_move.py b/account_move_line_sale_info/models/account_move.py
index 6e8cf8146..92611c2b0 100644
--- a/account_move_line_sale_info/models/account_move.py
+++ b/account_move_line_sale_info/models/account_move.py
@@ -47,3 +47,9 @@ class AccountMoveLine(models.Model):
index=True,
copy=False,
)
+
+ def _copy_data_extend_business_fields(self, values):
+ # Same way Odoo standard does for purchase_line_id field
+ res = super(AccountMoveLine, self)._copy_data_extend_business_fields(values)
+ values["sale_line_id"] = self.sale_line_id.id
+ return res
diff --git a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
index 000310c51..a33c42e62 100644
--- a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
+++ b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
@@ -170,7 +170,15 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
% (str(expected_balance), sale_line.name),
)
- def test_sale_invoice(self):
+ def move_reversal_wiz(self, move):
+ wizard = (
+ self.env["account.move.reversal"]
+ .with_context(active_model="account.move", active_ids=[move.id])
+ .create({"journal_id": move.journal_id.id})
+ )
+ return wizard
+
+ def test_01_sale_invoice(self):
"""Test that the po line moves from the sale order to the
account move line and to the invoice line.
"""
@@ -214,7 +222,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
"from the invoice to the account move line.",
)
- def test_name_get(self):
+ def test_02_name_get(self):
sale = self._create_sale([(self.product, 1)])
so_line = sale.order_line[0]
name_get = so_line.with_context(**{"so_line_info": True}).name_get()
@@ -242,3 +250,30 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
)
],
)
+
+ def test_03_credit_note(self):
+ """Test the credit note is linked to the sale order line"""
+ sale = self._create_sale([(self.product, 1)])
+ so_line = False
+ for line in sale.order_line:
+ so_line = line
+ break
+ sale.action_confirm()
+ picking = sale.picking_ids[0]
+ picking.move_lines.write({"quantity_done": 1.0})
+ picking.button_validate()
+ sale._create_invoices()
+ invoice = sale.invoice_ids[0]
+ invoice._post()
+ reversal_wizard = self.move_reversal_wiz(invoice)
+ credit_note = self.env["account.move"].browse(
+ reversal_wizard.reverse_moves()["res_id"]
+ )
+ for aml in credit_note.line_ids:
+ if aml.product_id == so_line.product_id and aml.move_id:
+ self.assertEqual(
+ aml.sale_line_id,
+ so_line,
+ "sale Order line has not been copied "
+ "from the invoice to the credit note.",
+ )
From f34b5a36bf8b87629d8c507a766c83d0bbf2cac9 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Thu, 15 Dec 2022 15:29:48 +0000
Subject: [PATCH 22/35] account_move_line_sale_info 15.0.1.0.2
---
account_move_line_sale_info/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index da7f0341c..74a7b21de 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Account Move Line Sale Info",
"summary": "Introduces the purchase order line to the journal items",
- "version": "15.0.1.0.1",
+ "version": "15.0.1.0.2",
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"category": "Generic",
From d7593600e95b1cde2b64cc2e773f60be5e156d30 Mon Sep 17 00:00:00 2001
From: AaronHForgeFlow
Date: Mon, 19 Dec 2022 17:40:22 +0100
Subject: [PATCH 23/35] [FIX]account_move_line_sale_info: picke info directly
form sale line ids field
---
account_move_line_sale_info/models/account_move.py | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/account_move_line_sale_info/models/account_move.py b/account_move_line_sale_info/models/account_move.py
index 92611c2b0..0bb4346b9 100644
--- a/account_move_line_sale_info/models/account_move.py
+++ b/account_move_line_sale_info/models/account_move.py
@@ -10,17 +10,11 @@ class AccountMove(models.Model):
def _stock_account_prepare_anglo_saxon_out_lines_vals(self):
res = super()._stock_account_prepare_anglo_saxon_out_lines_vals()
for i, vals in enumerate(res):
- if (
- not vals.get("move_id", False)
- or not vals.get("product_id", False)
- or not vals.get("quantity", False)
- ):
- continue
am = self.env["account.move"].browse(vals["move_id"])
sale_line_id = am.invoice_line_ids.filtered(
lambda il: il.product_id.id == vals["product_id"]
and il.quantity == vals["quantity"]
- ).mapped("sale_line_id")
+ ).mapped("sale_line_ids")
if sale_line_id and len(sale_line_id) == 1:
res[i]["sale_line_id"] = sale_line_id.id
return res
From 4201d24ee643c6e5022e71e66b854a812e181590 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Mon, 6 Feb 2023 09:33:21 +0000
Subject: [PATCH 24/35] account_move_line_sale_info 15.0.1.0.3
---
account_move_line_sale_info/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index 74a7b21de..c35e74337 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Account Move Line Sale Info",
"summary": "Introduces the purchase order line to the journal items",
- "version": "15.0.1.0.2",
+ "version": "15.0.1.0.3",
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"category": "Generic",
From ca0c6dd476154d8a20a0de8eda8ad835f5efa227 Mon Sep 17 00:00:00 2001
From: AlexPForgeFlow
Date: Fri, 4 Aug 2023 11:10:11 +0200
Subject: [PATCH 25/35] [MIG] account_move_line_sale_info: Migration to 16.0
---
account_move_line_sale_info/__manifest__.py | 4 ++--
account_move_line_sale_info/hooks.py | 2 +-
.../models/account_move.py | 2 +-
.../models/sale_order_line.py | 2 +-
.../models/stock_move.py | 6 +++---
.../readme/CONFIGURE.rst | 0
.../tests/test_account_move_line_sale_info.py | 21 +++++++------------
7 files changed, 15 insertions(+), 22 deletions(-)
delete mode 100644 account_move_line_sale_info/readme/CONFIGURE.rst
diff --git a/account_move_line_sale_info/__manifest__.py b/account_move_line_sale_info/__manifest__.py
index c35e74337..ae1989ac0 100644
--- a/account_move_line_sale_info/__manifest__.py
+++ b/account_move_line_sale_info/__manifest__.py
@@ -1,10 +1,10 @@
-# Copyright 2020 ForgeFlow S.L.
+# Copyright 2020-23 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Account Move Line Sale Info",
"summary": "Introduces the purchase order line to the journal items",
- "version": "15.0.1.0.3",
+ "version": "16.0.1.0.0",
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"category": "Generic",
diff --git a/account_move_line_sale_info/hooks.py b/account_move_line_sale_info/hooks.py
index cd6be3739..2ccdb260f 100644
--- a/account_move_line_sale_info/hooks.py
+++ b/account_move_line_sale_info/hooks.py
@@ -1,4 +1,4 @@
-# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019-23 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
diff --git a/account_move_line_sale_info/models/account_move.py b/account_move_line_sale_info/models/account_move.py
index 0bb4346b9..5996b3052 100644
--- a/account_move_line_sale_info/models/account_move.py
+++ b/account_move_line_sale_info/models/account_move.py
@@ -1,4 +1,4 @@
-# Copyright 2020 ForgeFlow S.L.
+# Copyright 2020-23 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
diff --git a/account_move_line_sale_info/models/sale_order_line.py b/account_move_line_sale_info/models/sale_order_line.py
index a46eeac9b..b6c8c109d 100644
--- a/account_move_line_sale_info/models/sale_order_line.py
+++ b/account_move_line_sale_info/models/sale_order_line.py
@@ -1,4 +1,4 @@
-# Copyright 2020 ForgeFlow S.L.
+# Copyright 2020-23 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models
diff --git a/account_move_line_sale_info/models/stock_move.py b/account_move_line_sale_info/models/stock_move.py
index 4f522e110..01627480f 100644
--- a/account_move_line_sale_info/models/stock_move.py
+++ b/account_move_line_sale_info/models/stock_move.py
@@ -1,4 +1,4 @@
-# Copyright 2020 ForgeFlow S.L.
+# Copyright 2020-23 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, models
@@ -8,10 +8,10 @@ class StockMove(models.Model):
@api.model
def _prepare_account_move_line(
- self, qty, cost, credit_account_id, debit_account_id, description
+ self, qty, cost, credit_account_id, debit_account_id, svl_id, description
):
res = super(StockMove, self)._prepare_account_move_line(
- qty, cost, credit_account_id, debit_account_id, description
+ qty, cost, credit_account_id, debit_account_id, svl_id, description
)
for line in res:
line[2]["sale_line_id"] = self.sale_line_id.id
diff --git a/account_move_line_sale_info/readme/CONFIGURE.rst b/account_move_line_sale_info/readme/CONFIGURE.rst
deleted file mode 100644
index e69de29bb..000000000
diff --git a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
index a33c42e62..756880ac0 100644
--- a/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
+++ b/account_move_line_sale_info/tests/test_account_move_line_sale_info.py
@@ -1,4 +1,4 @@
-# Copyright 2020 ForgeFlow S.L.
+# Copyright 2020-23 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests import common
@@ -10,7 +10,6 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
self.sale_line_model = self.env["sale.order.line"]
self.product_model = self.env["product.product"]
self.product_ctg_model = self.env["product.category"]
- self.acc_type_model = self.env["account.account.type"]
self.account_model = self.env["account.account"]
self.aml_model = self.env["account.move.line"]
self.res_users_model = self.env["res.users"]
@@ -23,18 +22,18 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
self.group_account_manager = self.env.ref("account.group_account_manager")
# Create account for Goods Received Not Invoiced
- acc_type = self._create_account_type("equity", "other")
+ acc_type = "equity"
name = "Goods Received Not Invoiced"
code = "grni"
self.account_grni = self._create_account(acc_type, name, code, self.company)
# Create account for Cost of Goods Sold
- acc_type = self._create_account_type("expense", "other")
+ acc_type = "expense"
name = "Cost of Goods Sold"
code = "cogs"
self.account_cogs = self._create_account(acc_type, name, code, self.company)
# Create account for Inventory
- acc_type = self._create_account_type("asset", "other")
+ acc_type = "asset_fixed"
name = "Inventory"
code = "inventory"
self.account_inventory = self._create_account(
@@ -81,19 +80,13 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
)
return user.id
- def _create_account_type(self, name, atype):
- acc_type = self.acc_type_model.create(
- {"name": name, "type": atype, "internal_group": name}
- )
- return acc_type
-
def _create_account(self, acc_type, name, code, company):
"""Create an account."""
account = self.account_model.create(
{
"name": name,
"code": code,
- "user_type_id": acc_type.id,
+ "account_type": acc_type,
"company_id": company.id,
}
)
@@ -189,7 +182,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
break
sale.action_confirm()
picking = sale.picking_ids[0]
- picking.move_lines.write({"quantity_done": 1.0})
+ picking.move_ids.write({"quantity_done": 1.0})
picking.button_validate()
expected_balance = -1.0
@@ -260,7 +253,7 @@ class TestAccountMoveLineSaleInfo(common.TransactionCase):
break
sale.action_confirm()
picking = sale.picking_ids[0]
- picking.move_lines.write({"quantity_done": 1.0})
+ picking.move_ids.write({"quantity_done": 1.0})
picking.button_validate()
sale._create_invoices()
invoice = sale.invoice_ids[0]
From 6cbf855ca1e44b227effe85b8f5a11da27cdc66d Mon Sep 17 00:00:00 2001
From: oca-ci
Date: Tue, 8 Aug 2023 10:55:33 +0000
Subject: [PATCH 26/35] [UPD] Update account_move_line_sale_info.pot
---
.../i18n/account_move_line_sale_info.pot | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/account_move_line_sale_info/i18n/account_move_line_sale_info.pot b/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
index 3b7599574..b05d4cda5 100644
--- a/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
+++ b/account_move_line_sale_info/i18n/account_move_line_sale_info.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 15.0\n"
+"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
From 3d10bf040130fcfc98ecb5e316e39f26c4b8f33b Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Tue, 8 Aug 2023 10:59:41 +0000
Subject: [PATCH 27/35] [UPD] README.rst
---
account_move_line_sale_info/README.rst | 10 +++++-----
.../static/description/index.html | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/account_move_line_sale_info/README.rst b/account_move_line_sale_info/README.rst
index ffc696039..da33b7e1a 100644
--- a/account_move_line_sale_info/README.rst
+++ b/account_move_line_sale_info/README.rst
@@ -14,13 +14,13 @@ Account Move Line Sale Info
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
- :target: https://github.com/OCA/account-financial-tools/tree/15.0/account_move_line_sale_info
+ :target: https://github.com/OCA/account-financial-tools/tree/16.0/account_move_line_sale_info
:alt: OCA/account-financial-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_move_line_sale_info
+ :target: https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_move_line_sale_info
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/92/15.0
+ :target: https://runbot.odoo-community.org/runbot/92/16.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -52,7 +52,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -82,6 +82,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-This module is part of the `OCA/account-financial-tools `_ project on GitHub.
+This module is part of the `OCA/account-financial-tools `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/account_move_line_sale_info/static/description/index.html b/account_move_line_sale_info/static/description/index.html
index 5d2370c9a..e193a1607 100644
--- a/account_move_line_sale_info/static/description/index.html
+++ b/account_move_line_sale_info/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module will add the sale order line to journal items.
The ultimate goal is to establish the purchase order line as one of the key
fields to reconcile the Goods Delivered Not Invoiced accrual account.
@@ -399,7 +399,7 @@ order line is copied to the account move line.
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -423,7 +423,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-
This module is part of the OCA/account-financial-tools project on GitHub.
+
This module is part of the OCA/account-financial-tools project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
From 33319b76999206a641d4400d207ae8bbaa320ab4 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Sun, 3 Sep 2023 11:22:10 +0000
Subject: [PATCH 28/35] [UPD] README.rst
---
account_move_line_sale_info/README.rst | 15 +++++---
.../static/description/index.html | 38 ++++++++++---------
2 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/account_move_line_sale_info/README.rst b/account_move_line_sale_info/README.rst
index da33b7e1a..7bdfad4a0 100644
--- a/account_move_line_sale_info/README.rst
+++ b/account_move_line_sale_info/README.rst
@@ -2,10 +2,13 @@
Account Move Line Sale Info
===========================
-.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+..
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! source digest: sha256:48bde197686bd1eb93a24461534e368906be593412432b8eee564670d8c768fc
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
@@ -19,11 +22,11 @@ Account Move Line Sale Info
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_move_line_sale_info
:alt: Translate me on Weblate
-.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/92/16.0
- :alt: Try me on Runbot
+.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=16.0
+ :alt: Try me on Runboat
-|badge1| |badge2| |badge3| |badge4| |badge5|
+|badge1| |badge2| |badge3| |badge4| |badge5|
This module will add the sale order line to journal items.
@@ -51,7 +54,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
-If you spotted it first, help us smashing it by providing a detailed and welcomed
+If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback `_.
Do not contact contributors directly about support or help with technical issues.
diff --git a/account_move_line_sale_info/static/description/index.html b/account_move_line_sale_info/static/description/index.html
index e193a1607..e958cb20d 100644
--- a/account_move_line_sale_info/static/description/index.html
+++ b/account_move_line_sale_info/static/description/index.html
@@ -1,20 +1,20 @@
-
+
-
+
Account Move Line Sale Info