Merge lp:~agilebg/account-invoice-report/adding_account_invoice_production_lot_7 into lp:~account-core-editors/account-invoice-report/7.0

Proposed by Lorenzo Battistini
Status: Merged
Merged at revision: 45
Proposed branch: lp:~agilebg/account-invoice-report/adding_account_invoice_production_lot_7
Merge into: lp:~account-core-editors/account-invoice-report/7.0
Diff against target: 397 lines (+360/-0)
7 files modified
account_invoice_production_lot/__init__.py (+24/-0)
account_invoice_production_lot/__openerp__.py (+49/-0)
account_invoice_production_lot/i18n/account_invoice_production_lot.pot (+53/-0)
account_invoice_production_lot/i18n/it.po (+52/-0)
account_invoice_production_lot/invoice.py (+79/-0)
account_invoice_production_lot/invoice_view.xml (+26/-0)
account_invoice_production_lot/test/sale.yml (+77/-0)
To merge this branch: bzr merge lp:~agilebg/account-invoice-report/adding_account_invoice_production_lot_7
Reviewer Review Type Date Requested Status
Maxime Chambreuil (http://www.savoirfairelinux.com) Approve
Alexis de Lattre (community) Needs Information
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Pedro Manuel Baeza code review and test Approve
Review via email: mp+191230@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Lorenzo, thank you very much for your efforts.

Only one minor thing:

- Please correct summary field to have "Display" instead of "Dislpay".

Regards.

review: Needs Fixing (code review and test)
Revision history for this message
Lorenzo Battistini (elbati) wrote :

On 10/16/2013 02:09 PM, Pedro Manuel Baeza wrote:
> Only one minor thing:
>
> - Please correct summary field to have "Display" instead of "Dislpay".

Oops. Done. Thanks.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Thank you!

review: Approve (code review and test)
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

LGTM !

review: Approve (code review, no tests)
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

Dear Lorenzo,

Thank you for this very interesting module. I was looking for such a module for a new development I want to do to replace my "fleet_maintenance" module (lp:fleet-maintenance).

Here are my remarks, from the most important to the least important :

1) the dependancy on invoice_webkit is not a good idea. I would really like to use this module, but I use aeroo reports. That would require splitting the module in 2 :
- one generic module "account_invoice_prodlots" that adds the field prod_lot_ids on the invoice lines,
- a second module "account_invoice_prodlots_webkit" with a dependancy on invoice_webkit which writes on "formatted_note" and adds the button "Load Lines Lots".
I think it's important to keep modules that bring additionnal functionalities independant from the reporting engine as much as we can.

2) for the field 'prod_lot_ids' in the invoice lines, I would prefer to have a fields.many2many instead of a field.function. Not only for performance reasons, but also for flexibility reasons. For example, as you will see in my specifications on the replacement of the fleet_maintenance module (cf https://docs.google.com/document/d/1EH1lnvkD3-aZjOTQ2jv_fTon1ZE0MzMm7hmmMgs9dJg/edit?usp=sharing), I want to have a many2many link from the invoice lines to the production lots for the maintenance service lines, in order to know on which prodlots the maintenance service apply. For that, the fields.function 'prod_lot_ids' needs to be converted to a fields.many2many. This many2many field would have to be set:
- when creating the invoice from the picking, by an inherit of the function _prepare_invoice_line() from stock/stock.py
- when creating the invoice from the sale order, by an inherit of the function _prepare_order_line_invoice_line() from sale/sale.py

If you think it's not a good idea and you want to keep the prod_lot_ids fields as field.function, then I will have to create another field 'maintenance_prodlot_ids' in the invoice lines that only applies for the maintenance service lines.

3) on the invoice line, you add a field 'displayed_lot_id' but you don't use it anywhere. What is this field for ?

4) on the stock moves, the many2one to the prodlot is called 'prodlot_id', so I would suggest to name the field 'prodlot_ids' instead of 'prod_lot_ids' on the invoice lines

review: Needs Information
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

@Lorenzo

I forgot to say that I am ready to do the work to have the changes that I suggest if you agree with the changes. I could do that in another branch and then propose to merge it.

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Hello,

just a word, to say that I fully agree with all Alexis comments: 1) to 4).
I don't remember where it was, but I believe there was a previous merge proposal (that has probably been dropped in favor of this one), where I believe Pedro Baeza was commenting the same that trying to avoid report_webkit would be ideal (that is split the module in two). Just like Alexis, I agree about prod_lot_ids becoming a regular m2m ideally unless mandatory this way.

If you do all that, we are probably going to get our Brazilian localization depends on that new module as for us mentioning product serial in the electronic invoice is mandatory and we hack it our own way currently.

Regards.

Revision history for this message
Lorenzo Battistini (elbati) wrote :

On 12/04/2013 05:01 PM, Alexis de Lattre wrote:
> 1) the dependancy on invoice_webkit is not a good idea. I would really like to use this module, but I use aeroo reports. That would require splitting the module in 2 :
> - one generic module "account_invoice_prodlots" that adds the field prod_lot_ids on the invoice lines,
> - a second module "account_invoice_prodlots_webkit" with a dependancy on invoice_webkit which writes on "formatted_note" and adds the button "Load Lines Lots".
> I think it's important to keep modules that bring additionnal functionalities independant from the reporting engine as much as we can.

Hello Alexis,

I think it's a good idea.

>
> 2) for the field 'prod_lot_ids' in the invoice lines, I would prefer to have a fields.many2many instead of a field.function. Not only for performance reasons, but also for flexibility reasons. For example, as you will see in my specifications on the replacement of the fleet_maintenance module (cf https://docs.google.com/document/d/1EH1lnvkD3-aZjOTQ2jv_fTon1ZE0MzMm7hmmMgs9dJg/edit?usp=sharing), I want to have a many2many link from the invoice lines to the production lots for the maintenance service lines, in order to know on which prodlots the maintenance service apply. For that, the fields.function 'prod_lot_ids' needs to be converted to a fields.many2many. This many2many field would have to be set:
> - when creating the invoice from the picking, by an inherit of the function _prepare_invoice_line() from stock/stock.py
> - when creating the invoice from the sale order, by an inherit of the function _prepare_order_line_invoice_line() from sale/sale.py
>
> If you think it's not a good idea and you want to keep the prod_lot_ids fields as field.function, then I will have to create another field 'maintenance_prodlot_ids' in the invoice lines that only applies for the maintenance service lines.

Maybe I'm not understanding how the maintenance service lines have to be
linked to prod lots, but:
I think we should make the prod_lot_ids field a simple m2m only if we
plan to have values different from the computed ones (manually changed
e.g.).
If the values of prod_lot_ids field are always equal to the computed
ones (in other words the field is always function of other fields in the
system), I think it should just be a stored function.
If the prod_lot_ids is differently computed whether the line is a
maintenance service or not, maybe you can just extend the
fields.function method?
Am I missing some requirement?

>
> 3) on the invoice line, you add a field 'displayed_lot_id' but you don't use it anywhere. What is this field for ?

It can be dropped.

>
> 4) on the stock moves, the many2one to the prodlot is called 'prodlot_id', so I would suggest to name the field 'prodlot_ids' instead of 'prod_lot_ids' on the invoice lines

It's ok for me.

Thank you very much for your contribution Alexis

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

@Lorenzo :

I see that we agree on points 1, 3 and 4.

My answer on point 2 : after reflexion, I eventually think that a fields.function is fine. It will be OK for me to use another many2many field for the link between maintenance invoice lines and prodlots, or inherit the fields.function. And if you have a perf problem, we can always add a store={} to the current fields.function.

By the way, do you want me to sumbit a patch for points 1, 3 and 4, or do you plan to do it yourself ?

Revision history for this message
Lorenzo Battistini (elbati) wrote :

On 12/05/2013 11:49 PM, Alexis de Lattre wrote:
> @Lorenzo :
>
> I see that we agree on points 1, 3 and 4.
>
> My answer on point 2 : after reflexion, I eventually think that a fields.function is fine. It will be OK for me to use another many2many field for the link between maintenance invoice lines and prodlots, or inherit the fields.function. And if you have a perf problem, we can always add a store={} to the current fields.function.

Sorry, I thought you also wanted to increase performances.
For me, for now, it can stay a normal function.

> By the way, do you want me to sumbit a patch for points 1, 3 and 4, or do you plan to do it yourself ?

Unfortunately, we can't work on that in the next days.
So, if you want to submit the patches, it's perfect.

Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) wrote :

Hello Lorenzo,

Please remove the AUTHORS.txt file and add its content to the module description.

Thanks.

review: Needs Fixing (code review)
Revision history for this message
Nicola Malcontenti - Agile BG (hurrin1c0) wrote :

Hello Maxime,
i have removed the file and added the author to the module.
Thanks.

Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

I see that this module got merged without modification, and none of the points that I raise in my review were addressed, which is a bit surprising.

For example, the point 3 that I raised was :
<<
on the invoice line, you add a field 'displayed_lot_id' but you don't use it anywhere. What is this field for ?
>>

Lorenzo answered that this field was useless and could be removed. But the module was commited to the branch with this field. So we have a just added a module with a field that nobody knows what it is for.

Joël, why did you commit the module without changes ? We could have at least cleaned-up this !

Revision history for this message
banane (k-paolo) wrote :

does anyone know how to make the S/N text translatable?

> u'<li>S/N {0}</li>'.format(lot.name)

I would like to have it translated in the right language in my webkit invoices
many thanks

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Ciao banane,
you have to use
from openerp.tools.translate import _ (see for instance https://github.com/OCA/account-invoice-reporting/blob/7.0/invoice_webkit/invoice.py#L52 )

Anyway, the project has moved to github. Please open an issue (or better a PR) at https://github.com/OCA/account-invoice-reporting

Thanks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_invoice_production_lot'
2=== added file 'account_invoice_production_lot/__init__.py'
3--- account_invoice_production_lot/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_invoice_production_lot/__init__.py 2014-01-02 10:05:23 +0000
5@@ -0,0 +1,24 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Author: Lorenzo Battistini <lorenzo.battistini@agilebg.com>
11+# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
12+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
13+#
14+# This program is free software: you can redistribute it and/or modify
15+# it under the terms of the GNU Affero General Public License as
16+# published by the Free Software Foundation, either version 3 of the
17+# License, or (at your option) any later version.
18+#
19+# This program is distributed in the hope that it will be useful,
20+# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+# GNU Affero General Public License for more details.
23+#
24+# You should have received a copy of the GNU Affero General Public License
25+# along with this program. If not, see <http://www.gnu.org/licenses/>.
26+#
27+##############################################################################
28+
29+from . import invoice
30
31=== added file 'account_invoice_production_lot/__openerp__.py'
32--- account_invoice_production_lot/__openerp__.py 1970-01-01 00:00:00 +0000
33+++ account_invoice_production_lot/__openerp__.py 2014-01-02 10:05:23 +0000
34@@ -0,0 +1,49 @@
35+# -*- coding: utf-8 -*-
36+##############################################################################
37+#
38+# OpenERP, Open Source Management Solution
39+# Author: Lorenzo Battistini <lorenzo.battistini@agilebg.com>
40+# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
41+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
42+#
43+# This program is free software: you can redistribute it and/or modify
44+# it under the terms of the GNU Affero General Public License as
45+# published by the Free Software Foundation, either version 3 of the
46+# License, or (at your option) any later version.
47+#
48+# This program is distributed in the hope that it will be useful,
49+# but WITHOUT ANY WARRANTY; without even the implied warranty of
50+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51+# GNU Affero General Public License for more details.
52+#
53+# You should have received a copy of the GNU Affero General Public License
54+# along with this program. If not, see <http://www.gnu.org/licenses/>.
55+#
56+##############################################################################
57+
58+
59+{
60+ "name": "Invoice Production Lots",
61+ "version": "1.1",
62+ 'category': 'Generic Modules/Accounting',
63+ "depends": [
64+ "sale_stock",
65+ "invoice_webkit",
66+ ],
67+ "author": "Agile Business Group",
68+ "summary": "Display delivered serial numbers in invoice",
69+ "description": """
70+This module prints, for each (customer) invoice line, the delivered production
71+lots. The serial numbers are displayed in the "formatted note" field,
72+introduced by invoice_webkit module""",
73+ 'website': 'http://www.agilebg.com',
74+ 'data': [
75+ 'invoice_view.xml',
76+ ],
77+ 'demo': [],
78+ 'test': [
79+ 'test/sale.yml',
80+ ],
81+ 'installable': True,
82+ 'active': False,
83+}
84
85=== added directory 'account_invoice_production_lot/i18n'
86=== added file 'account_invoice_production_lot/i18n/account_invoice_production_lot.pot'
87--- account_invoice_production_lot/i18n/account_invoice_production_lot.pot 1970-01-01 00:00:00 +0000
88+++ account_invoice_production_lot/i18n/account_invoice_production_lot.pot 2014-01-02 10:05:23 +0000
89@@ -0,0 +1,53 @@
90+# Translation of OpenERP Server.
91+# This file contains the translation of the following modules:
92+# * account_invoice_production_lot
93+#
94+msgid ""
95+msgstr ""
96+"Project-Id-Version: OpenERP Server 7.0\n"
97+"Report-Msgid-Bugs-To: \n"
98+"POT-Creation-Date: 2013-08-23 08:50+0000\n"
99+"PO-Revision-Date: 2013-08-23 08:50+0000\n"
100+"Last-Translator: <>\n"
101+"Language-Team: \n"
102+"MIME-Version: 1.0\n"
103+"Content-Type: text/plain; charset=UTF-8\n"
104+"Content-Transfer-Encoding: \n"
105+"Plural-Forms: \n"
106+
107+#. module: account_invoice_production_lot
108+#: model:ir.model,name:account_invoice_production_lot.model_account_invoice
109+msgid "Invoice"
110+msgstr ""
111+
112+#. module: account_invoice_production_lot
113+#: view:account.invoice:0
114+msgid "Load Lines Lots"
115+msgstr ""
116+
117+#. module: account_invoice_production_lot
118+#: model:ir.model,name:account_invoice_production_lot.model_account_invoice_line
119+msgid "Invoice Line"
120+msgstr ""
121+
122+#. module: account_invoice_production_lot
123+#: field:account.invoice.line,displayed_lot_id:0
124+msgid "Lot"
125+msgstr ""
126+
127+#. module: account_invoice_production_lot
128+#: view:account.invoice.line:0
129+#: field:account.invoice.line,prod_lot_ids:0
130+msgid "Production Lots"
131+msgstr ""
132+
133+#. module: account_invoice_production_lot
134+#: field:account.invoice.line,order_lines:0
135+msgid "Order Lines"
136+msgstr ""
137+
138+#. module: account_invoice_production_lot
139+#: view:account.invoice:0
140+msgid "This will overwrite the formatted note. Continue?"
141+msgstr ""
142+
143
144=== added file 'account_invoice_production_lot/i18n/it.po'
145--- account_invoice_production_lot/i18n/it.po 1970-01-01 00:00:00 +0000
146+++ account_invoice_production_lot/i18n/it.po 2014-01-02 10:05:23 +0000
147@@ -0,0 +1,52 @@
148+# Translation of OpenERP Server.
149+# This file contains the translation of the following modules:
150+# * account_invoice_production_lot
151+#
152+msgid ""
153+msgstr ""
154+"Project-Id-Version: OpenERP Server 7.0\n"
155+"Report-Msgid-Bugs-To: \n"
156+"POT-Creation-Date: 2013-08-23 08:49+0000\n"
157+"PO-Revision-Date: 2013-08-23 10:51+0100\n"
158+"Last-Translator: Lorenzo Battistini <lorenzo.battistini@agilebg.com>\n"
159+"Language-Team: \n"
160+"MIME-Version: 1.0\n"
161+"Content-Type: text/plain; charset=UTF-8\n"
162+"Content-Transfer-Encoding: 8bit\n"
163+"Plural-Forms: \n"
164+"X-Generator: Poedit 1.5.4\n"
165+
166+#. module: account_invoice_production_lot
167+#: model:ir.model,name:account_invoice_production_lot.model_account_invoice
168+msgid "Invoice"
169+msgstr "Fattura"
170+
171+#. module: account_invoice_production_lot
172+#: view:account.invoice:0
173+msgid "Load Lines Lots"
174+msgstr "Carica i lotti delle righe"
175+
176+#. module: account_invoice_production_lot
177+#: model:ir.model,name:account_invoice_production_lot.model_account_invoice_line
178+msgid "Invoice Line"
179+msgstr "Righe Fattura"
180+
181+#. module: account_invoice_production_lot
182+#: field:account.invoice.line,displayed_lot_id:0
183+msgid "Lot"
184+msgstr "Lotto"
185+
186+#. module: account_invoice_production_lot
187+#: view:account.invoice.line:0 field:account.invoice.line,prod_lot_ids:0
188+msgid "Production Lots"
189+msgstr "Lotti di produzione"
190+
191+#. module: account_invoice_production_lot
192+#: field:account.invoice.line,order_lines:0
193+msgid "Order Lines"
194+msgstr "Righe ordine"
195+
196+#. module: account_invoice_production_lot
197+#: view:account.invoice:0
198+msgid "This will overwrite the formatted note. Continue?"
199+msgstr "Questo sovrascriverà la note formattate. Continuare?"
200
201=== added file 'account_invoice_production_lot/invoice.py'
202--- account_invoice_production_lot/invoice.py 1970-01-01 00:00:00 +0000
203+++ account_invoice_production_lot/invoice.py 2014-01-02 10:05:23 +0000
204@@ -0,0 +1,79 @@
205+# -*- coding: utf-8 -*-
206+##############################################################################
207+#
208+# OpenERP, Open Source Management Solution
209+# Author: Lorenzo Battistini <lorenzo.battistini@agilebg.com>
210+# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
211+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
212+#
213+# This program is free software: you can redistribute it and/or modify
214+# it under the terms of the GNU Affero General Public License as
215+# published by the Free Software Foundation, either version 3 of the
216+# License, or (at your option) any later version.
217+#
218+# This program is distributed in the hope that it will be useful,
219+# but WITHOUT ANY WARRANTY; without even the implied warranty of
220+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
221+# GNU Affero General Public License for more details.
222+#
223+# You should have received a copy of the GNU Affero General Public License
224+# along with this program. If not, see <http://www.gnu.org/licenses/>.
225+#
226+##############################################################################
227+
228+from openerp.osv import fields, orm
229+
230+
231+class account_invoice_line(orm.Model):
232+
233+ def _get_prod_lots(self, cr, uid, ids, field_name, arg, context=None):
234+ result = {}
235+ for line in self.browse(cr, uid, ids, context=context):
236+ result[line.id] = []
237+ for order_line in line.order_lines:
238+ for move in order_line.move_ids:
239+ if move.prodlot_id:
240+ result[line.id].append(move.prodlot_id.id)
241+ return result
242+
243+ _inherit = "account.invoice.line"
244+
245+ _columns = {
246+ # order_lines is the reverse of invoice_lines field of sale module
247+ 'order_lines': fields.many2many(
248+ 'sale.order.line', 'sale_order_line_invoice_rel', 'invoice_id',
249+ 'order_line_id', 'Order Lines', readonly=True),
250+ 'prod_lot_ids': fields.function(
251+ _get_prod_lots, method=True, type='many2many',
252+ relation="stock.production.lot", string="Production Lots"),
253+ 'displayed_lot_id': fields.many2one('stock.production.lot', 'Lot'),
254+ }
255+
256+ def load_line_lots(self, cr, uid, ids, context=None):
257+ for line in self.browse(cr, uid, ids, context):
258+ if line.prod_lot_ids:
259+ note = u'<ul> '
260+ note += u' '.join([
261+ u'<li>S/N {0}</li>'.format(lot.name)
262+ for lot in line.prod_lot_ids
263+ ])
264+ note += u' </ul>'
265+ line.write({'formatted_note': note}, context=context)
266+ return True
267+
268+ def create(self, cr, uid, vals, context=None):
269+ res = super(account_invoice_line, self).create(cr, uid, vals, context)
270+ if not vals.get('formatted_note'):
271+ self.load_line_lots(cr, uid, [res], context)
272+ return res
273+
274+class account_invoice(orm.Model):
275+
276+ def load_lines_lots(self, cr, uid, ids, context=None):
277+ invoices = self.browse(cr, uid, ids, context)
278+ inv_line_obj = self.pool.get('account.invoice.line')
279+ for invoice in invoices:
280+ inv_line_obj.load_line_lots(cr, uid, [l.id for l in invoice.invoice_line], context)
281+ return True
282+
283+ _inherit = "account.invoice"
284
285=== added file 'account_invoice_production_lot/invoice_view.xml'
286--- account_invoice_production_lot/invoice_view.xml 1970-01-01 00:00:00 +0000
287+++ account_invoice_production_lot/invoice_view.xml 2014-01-02 10:05:23 +0000
288@@ -0,0 +1,26 @@
289+<?xml version="1.0" encoding="UTF-8"?>
290+<openerp>
291+ <data>
292+ <record model="ir.ui.view" id="view_invoice_line_form_prod_lots">
293+ <field name="name">account.invoice.line.form.prod_lots</field>
294+ <field name="model">account.invoice.line</field>
295+ <field name="inherit_id" ref="account.view_invoice_line_form"/>
296+ <field name="arch" type="xml">
297+ <field name="name" position="after">
298+ <separator colspan="4" string="Production Lots"/>
299+ <field colspan="4" name="prod_lot_ids" nolabel="1"/>
300+ </field>
301+ </field>
302+ </record>
303+ <record model="ir.ui.view" id="invoice_form_load_button">
304+ <field name="name">account.invoice.form.load_button</field>
305+ <field name="model">account.invoice</field>
306+ <field name="inherit_id" ref="account.invoice_form"/>
307+ <field name="arch" type="xml">
308+ <field name="invoice_line" position="after">
309+ <button name="load_lines_lots" type="object" string="Load Lines Lots" colspan="2" confirm="This will overwrite the formatted note. Continue?"/>
310+ </field>
311+ </field>
312+ </record>
313+ </data>
314+</openerp>
315
316=== added directory 'account_invoice_production_lot/test'
317=== added file 'account_invoice_production_lot/test/sale.yml'
318--- account_invoice_production_lot/test/sale.yml 1970-01-01 00:00:00 +0000
319+++ account_invoice_production_lot/test/sale.yml 2014-01-02 10:05:23 +0000
320@@ -0,0 +1,77 @@
321+-
322+ !record {model: stock.location, id: location_opening}:
323+ name: opening
324+ usage: inventory
325+-
326+ !record {model: product.product, id: product_icecream}:
327+ default_code: 001
328+ name: Ice Cream
329+ type: product
330+ categ_id: product.product_category_1
331+ list_price: 100.0
332+ standard_price: 70.0
333+ uom_id: product.product_uom_kgm
334+ uom_po_id: product.product_uom_kgm
335+ procure_method: make_to_stock
336+ property_stock_inventory: location_opening
337+ valuation: real_time
338+ cost_method: average
339+ property_stock_account_input: account.o_expense
340+ property_stock_account_output: account.o_income
341+ description: Ice cream can be mass-produced and thus is widely available in developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds) from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience stores, and milk bars, and in individual servings from small carts or vans at public events.
342+-
343+ !record {model: stock.production.lot, id: lot_icecream_0}:
344+ name: Lot0 for Ice cream
345+ product_id: product_icecream
346+-
347+ I create a draft Sale Order
348+-
349+ !record {model: sale.order, id: sale_order}:
350+ partner_id: base.res_partner_2
351+ partner_invoice_id: base.res_partner_address_3
352+ partner_shipping_id: base.res_partner_address_3
353+ pricelist_id: 1
354+ order_policy: picking
355+ order_line:
356+ - product_id: product_icecream
357+ product_uom_qty: 1.0
358+ product_uom: 1
359+ price_unit: 100.0
360+-
361+ I confirm the quotation with Invoice based on deliveries policy.
362+-
363+ !workflow {model: sale.order, action: order_confirm, ref: sale_order}
364+-
365+ Now, I dispatch delivery order.
366+-
367+ !python {model: stock.partial.picking}: |
368+ order = self.pool.get('sale.order').browse(cr, uid, ref("sale_order"))
369+ for pick in order.picking_ids:
370+ data = pick.force_assign()
371+ if data == True:
372+ partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick.id]})
373+ partial = self.browse(cr, uid, partial_id)
374+ partial.move_ids[0].write({
375+ 'prodlot_id': ref("lot_icecream_0"),
376+ })
377+ self.do_partial(cr, uid, [partial_id])
378+-
379+ I create Invoice from Delivery Order.
380+-
381+ !python {model: stock.invoice.onshipping}: |
382+ sale = self.pool.get('sale.order')
383+ sale_order = sale.browse(cr, uid, ref("sale_order"))
384+ ship_ids = [x.id for x in sale_order.picking_ids]
385+ wiz_id = self.create(cr, uid, {'journal_id': ref('account.sales_journal')},
386+ {'active_ids': ship_ids, 'active_model': 'stock.picking'})
387+ self.create_invoice(cr, uid, [wiz_id], {"active_ids": ship_ids, "active_id": ship_ids[0]})
388+-
389+ I check the invoice details after dispatched delivery.
390+-
391+ !python {model: sale.order}: |
392+ order = self.browse(cr, uid, ref("sale_order"))
393+ assert order.invoice_ids, "Invoice is not created."
394+ ac = order.partner_invoice_id.property_account_receivable.id
395+ for invoice in order.invoice_ids:
396+ invoice.load_lines_lots()
397+ assert invoice.invoice_line[0].formatted_note == '<ul> <li>S/N Lot0 for Ice cream</li> </ul>', "Wrgong formatted note for '%s' line" % invoice.invoice_line[0].name

Subscribers

People subscribed via source and target branches