Merge lp:~jfb-tempo-consulting/unifield-server/US-8839 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 6110
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-8839
Merge into: lp:unifield-server
Diff against target: 8352 lines (+2680/-2228)
75 files modified
bin/addons/account/account.py (+39/-0)
bin/addons/account/account_invoice_payment_tab.xml (+1/-1)
bin/addons/account/account_invoice_view.xml (+376/-113)
bin/addons/account/account_menuitem.xml (+1/-1)
bin/addons/account/account_view.xml (+154/-67)
bin/addons/account/invoice.py (+125/-103)
bin/addons/account/report/account_print_invoice.rml (+1/-0)
bin/addons/account/report/export_invoice.py (+4/-4)
bin/addons/account/report/invoice_excel_export.py (+25/-20)
bin/addons/account/wizard/account_invoice_import.py (+1/-1)
bin/addons/account/wizard/account_invoice_refund.py (+48/-56)
bin/addons/account/wizard/account_invoice_refund_view.xml (+7/-3)
bin/addons/account_hq_entries/account_view.xml (+0/-34)
bin/addons/account_mcdb/account_view.xml (+0/-24)
bin/addons/account_override/__init__.py (+6/-0)
bin/addons/account_override/account.py (+1/-0)
bin/addons/account_override/account_invoice_sync.py (+17/-13)
bin/addons/account_override/account_invoice_view.xml (+14/-314)
bin/addons/account_override/account_view.xml (+0/-95)
bin/addons/account_override/invoice.py (+251/-219)
bin/addons/account_override/report/account_print_invoice.rml (+4/-3)
bin/addons/account_override/report/open_invoices_xls.mako (+9/-7)
bin/addons/account_override/report/report_open_invoices.py (+6/-34)
bin/addons/account_payment/__openerp__.py (+0/-1)
bin/addons/account_period_closing_level/account_period.py (+53/-36)
bin/addons/account_period_closing_level/account_period_closing_level_view.xml (+4/-1)
bin/addons/account_period_closing_level/account_year_end_closing.xml (+1/-16)
bin/addons/account_subscription/account_model_view.xml (+1/-1)
bin/addons/analytic_distribution/account_commitment.py (+120/-24)
bin/addons/analytic_distribution/account_commitment_view.xml (+140/-21)
bin/addons/analytic_distribution/account_invoice_refund.py (+49/-13)
bin/addons/analytic_distribution/account_invoice_view.xml (+5/-65)
bin/addons/analytic_distribution/account_view.xml (+0/-32)
bin/addons/analytic_distribution/analytic_line_view.xml (+3/-39)
bin/addons/analytic_distribution_supply/__openerp__.py (+0/-1)
bin/addons/analytic_distribution_supply/invoice.py (+67/-34)
bin/addons/base/__openerp__.py (+1/-1)
bin/addons/base/ir/ir_actions.py (+1/-1)
bin/addons/base/migrations/8.0.1.7/pre-update-bar.py (+22/-0)
bin/addons/base/migrations/8.0.1.7/update_bar_sdref.sql (+108/-0)
bin/addons/base/module/instance_auto_creation.py (+8/-0)
bin/addons/finance/account_analytic_line_view.xml (+16/-1)
bin/addons/finance/account_view.xml (+0/-34)
bin/addons/finance/board_account_view.xml (+5/-5)
bin/addons/msf_accrual/__openerp__.py (+0/-1)
bin/addons/msf_currency_revaluation/__openerp__.py (+0/-1)
bin/addons/msf_doc_import/wizard/wizard_import_invoice_line.py (+3/-102)
bin/addons/msf_instance/msf_instance_view.xml (+0/-13)
bin/addons/msf_outgoing/msf_outgoing.py (+26/-22)
bin/addons/msf_partner/partner.py (+40/-22)
bin/addons/msf_profile/data/patches.xml (+8/-0)
bin/addons/msf_profile/i18n/es_MF.po (+3/-107)
bin/addons/msf_profile/i18n/fr_MF.po (+455/-186)
bin/addons/msf_profile/msf_profile.py (+57/-2)
bin/addons/msf_sync_data_post_synchro/data/account.analytic.journal.csv (+1/-0)
bin/addons/msf_sync_data_post_synchro/data/account.journal.csv (+1/-0)
bin/addons/product_attributes/product_attributes.py (+31/-42)
bin/addons/purchase/purchase_order.py (+2/-3)
bin/addons/purchase/purchase_order_line.py (+1/-1)
bin/addons/register_accounting/account_bank_statement.py (+29/-34)
bin/addons/register_accounting/account_invoice_view.xml (+4/-126)
bin/addons/register_accounting/account_view.xml (+0/-103)
bin/addons/register_accounting/wizard/account_direct_invoice_wizard_view.xml (+1/-1)
bin/addons/sale/sale_order.py (+58/-1)
bin/addons/sale/sale_workflow.py (+95/-3)
bin/addons/stock/stock.py (+37/-20)
bin/addons/stock_override/stock.py (+1/-0)
bin/addons/unifield_setup/__openerp__.py (+1/-0)
bin/addons/unifield_setup/installer/__init__.py (+1/-0)
bin/addons/unifield_setup/installer/customer_commitment_voucher.xml (+55/-0)
bin/addons/unifield_setup/installer/customer_commitment_voucher_setup.py (+67/-0)
bin/addons/unifield_setup/setup_configuration.py (+2/-0)
bin/import_xml.rng (+1/-0)
bin/osv/orm.py (+2/-0)
bin/tools/convert.py (+4/-0)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-8839
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+411252@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/account/account.py'
2--- bin/addons/account/account.py 2021-01-28 17:59:49 +0000
3+++ bin/addons/account/account.py 2021-11-03 13:33:55 +0000
4@@ -580,6 +580,43 @@
5 class account_journal(osv.osv):
6 _name = "account.journal"
7 _description = "Journal"
8+
9+ def _get_false(self, cr, uid, ids, *a, **b):
10+ """
11+ Returns False for all ids (cf. only the search method is used for the field)
12+ """
13+ return {}.fromkeys(ids, False)
14+
15+ def _search_inv_doc_type(self, cr, uid, obj, name, args, context=None):
16+ """
17+ Returns a domain (based on the context) to get all journals matching with the doc type of the selected invoice
18+ """
19+ if context is None:
20+ context = {}
21+ if not args:
22+ return []
23+ doc_type = context.get('doc_type', '')
24+ if doc_type == 'str':
25+ journal_types = ['sale']
26+ elif doc_type in ('isi', 'isr'):
27+ journal_types = ['purchase']
28+ elif doc_type == 'donation':
29+ journal_types = ['inkind', 'extra']
30+ else:
31+ journals = {
32+ 'out_invoice': 'sale',
33+ 'in_invoice': 'purchase',
34+ 'out_refund': 'sale_refund',
35+ 'in_refund': 'purchase_refund',
36+ }
37+ journal_types = [journals.get(context.get('type', ''), 'purchase')]
38+ journal_dom = [('type', 'in', journal_types), ('is_current_instance', '=', True)]
39+ if doc_type in ('isi', 'isr'):
40+ journal_dom.append(('code', '=', 'ISI'))
41+ else:
42+ journal_dom.append(('code', '!=', 'ISI'))
43+ return journal_dom
44+
45 _columns = {
46 'name': fields.char('Journal Name', size=64, required=True),
47 'code': fields.char('Code', size=5, required=True, help="The code will be used to generate the numbers of the journal entries of this journal."),
48@@ -609,6 +646,8 @@
49 'bank_account_name': fields.char('Bank Account Name', size=256, required=False),
50 'bank_swift_code': fields.char('Swift Code', size=32, required=False),
51 'bank_address': fields.text('Address', required=False),
52+ 'inv_doc_type': fields.function(_get_false, method=True, type='boolean', string='Document Type', store=False,
53+ fnct_search=_search_inv_doc_type),
54 }
55
56 _defaults = {
57
58=== modified file 'bin/addons/account/account_invoice_payment_tab.xml'
59--- bin/addons/account/account_invoice_payment_tab.xml 2021-01-29 15:17:52 +0000
60+++ bin/addons/account/account_invoice_payment_tab.xml 2021-11-03 13:33:55 +0000
61@@ -1,5 +1,5 @@
62 <!-- PAYMENT TAB -->
63-<!-- added in SI / SR / IVO / STV -->
64+<!-- added in SI / SR / ISI / ISR / IVO / STV -->
65 <page string="Payments"
66 attrs="{'invisible': [('type', 'not in', ('in_refund', 'out_invoice')),
67 '|', ('type', '!=', 'in_invoice'), ('is_intermission', '=', True)]}">
68
69=== modified file 'bin/addons/account/account_invoice_view.xml'
70--- bin/addons/account/account_invoice_view.xml 2021-01-29 15:17:52 +0000
71+++ bin/addons/account/account_invoice_view.xml 2021-11-03 13:33:55 +0000
72@@ -144,6 +144,9 @@
73 <field name="type">tree</field>
74 <field name="arch" type="xml">
75 <tree colors="blue:state in ('draft');black:state in ('proforma','proforma2','open');gray:state in ('cancel')" string="Invoice">
76+ <field name="document_date"/>
77+ <field name="supplier_reference"/>
78+
79 <field name="date_invoice"/>
80 <field name="number"/>
81 <field name="partner_id" groups="base.group_user"/>
82@@ -151,17 +154,14 @@
83 <field name="journal_id" invisible="1"/>
84 <field name="period_id" invisible="1" groups="account.group_account_user"/>
85 <field name="company_id" groups="base.group_multi_company" widget="selection"/>
86- <field name="user_id"/>
87 <field name="date_due"/>
88 <field name="origin"/>
89 <field name="line_count"/>
90 <field name="currency_id"/>
91- <field name="residual" sum="Residual Amount"/>
92- <field name="amount_untaxed" sum="Untaxed Amount"/>
93- <field name="amount_total" sum="Total Amount"/>
94+ <field name="residual" />
95+ <field name="amount_total"/>
96 <field name="state"/>
97-
98- <button name="invoice_open" states="draft,proforma2" string="Approve" icon="terp-camera_test"/>
99+ <button name="invoice_open" states="draft,proforma2" type="object" string="Approve" icon="terp-camera_test"/>
100 </tree>
101 </field>
102 </record>
103@@ -174,7 +174,10 @@
104 <field name="arch" type="xml">
105 <form string="Supplier Invoice">
106 <group col="8" colspan="4">
107- <field name="journal_id" widget="selection"/>
108+ <field name="journal_id"
109+ domain="[('inv_doc_type', '=', True)]"
110+ attrs="{'readonly': ['|', ('state', '!=', 'draft'), '&amp;', ('type', '=', 'in_invoice'), ('synced', '=', True)]}"/>
111+ <field name="vat_ok" invisible="1" />
112 <field name="number" readonly="1"/>
113 <field name="type" invisible="1"/>
114 <field name="is_intermission" invisible="1"/> <!-- for Payment tab -->
115@@ -186,7 +189,7 @@
116 'readonly': [('type', '=', 'in_invoice'), ('synced', '=', True)]}"/>
117 <newline/>
118 <field string="Supplier" name="partner_id" domain="[('supplier', '=', True)]"
119- on_change="onchange_partner_id(type, partner_id, date_invoice, payment_term, partner_bank_id, company_id)"
120+ on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term,partner_bank_id,company_id,is_inkind_donation,is_intermission,is_debit_note,is_direct_invoice,False)"
121 context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}"
122 attrs="{'readonly': ['|',
123 ('state', '!=', 'draft'),
124@@ -195,25 +198,52 @@
125 <field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
126 <field name="fiscal_position" groups="base.group_extended" widget="selection"/>
127 <newline/>
128+ <field name="document_date" />
129 <field name="date_invoice"/>
130- <field name="period_id" domain="[('state', '=', 'draft')]" groups="account.group_account_user" widget="selection"/>
131- <group colspan="2" col="1" groups="account.group_account_user">
132- <label align="0.0" string="(keep empty to use the current period)"/>
133- </group>
134- </group>
135+ <group colspan="2" col="1" />
136+ </group>
137+ <newline />
138+ <group colspan="4" col="8" attrs="{'invisible': [('analytic_distribution_id', '=', False)]}">
139+ <button name="button_analytic_distribution" string="Analytical Distribution" type="object" icon="terp-check" context="context" colspan="4" attrs="{'invisible': [('analytic_distribution_id', '=', False)]}"/>
140+ <button name="button_reset_distribution" string="Reset AD at line level" type="object" icon="gtk-undelete" colspan="4" states="draft"/>
141+ </group>
142+ <group colspan="4" col="8" attrs="{'invisible': [('analytic_distribution_id', '!=', False)]}">
143+ <button name="button_analytic_distribution" string="Analytical Distribution" type="object" icon="terp-emblem-important" context="context" colspan="4" attrs="{'invisible': [('analytic_distribution_id', '!=', False)]}"/>
144+ <button name="button_reset_distribution" string="Reset AD at line level" type="object" icon="gtk-undelete" colspan="4" states="draft"/>
145+ </group>
146+ <field name="analytic_distribution_id" invisible="1"/>
147+ <group colspan="3"/>
148+
149 <notebook colspan="4">
150 <page string="Invoice">
151- <field domain="[('company_id', '=', company_id), ('type', '=', 'payable')]" name="account_id" groups="account.group_account_user"/>
152+ <field domain="[('company_id', '=', company_id), ('restricted_area', '=', 'in_invoice')]" name="account_id" />
153 <field name="reference_type" nolabel="1" size="0"/>
154 <field name="reference" nolabel="1"/>
155 <field name="date_due"/>
156 <field name="check_total" required="2"/>
157+ <field name="supplier_reference"/>
158+ <group name="import" string=" Import Lines " colspan="4" col="4"
159+ attrs="{'invisible': [('state', '!=', 'draft'), ('type', '!=', 'in_invoice')]}">
160+ <button name="import_invoice" string="Import Invoice Line" icon="gtk-execute" colspan="2" type="object"
161+ attrs="{'readonly': [('state', '!=', 'draft')],
162+ 'invisible': [('type', '!=', 'in_invoice')]}"/>
163+ <button name="export_invoice" string="Export Invoice Line" icon="gtk-execute" colspan="2" type="object"
164+ attrs="{'invisible': [('type', '!=', 'in_invoice')]}"/>
165+ <newline/>
166+ <button name="wizard_import_si_line" string="Import lines" icon="gtk-dnd" colspan="4" type="object"
167+ attrs="{'invisible': [('state', '!=', 'draft')],
168+ 'readonly': [('type', '=', 'in_invoice'), ('synced', '=', True)]}"/>
169+ </group>
170+
171 <field colspan="4" default_get="{'check_total': check_total, 'invoice_line': invoice_line, 'address_invoice_id': address_invoice_id, 'partner_id': partner_id, 'price_type': 'price_type' in dir() and price_type or False}" name="invoice_line" nolabel="1">
172- <tree string="Invoice lines" editable="both">
173+ <tree string="Invoice lines" editable="both" colors="red:analytic_distribution_state in ('invalid', 'invalid_small_amount') or inactive_product == True;black:analytic_distribution_state in ('none','valid') and inactive_product == False">
174 <field name="from_supply" invisible="1"/>
175 <field name="line_synced" invisible="1"/>
176 <field name="invoice_type" invisible="1"/>
177 <field name="partner_type" invisible="1"/>
178+ <field name="line_number" displayon="noteditable"/>
179+ <field name="is_corrected" invisible="1"/>
180+ <button name="button_open_analytic_lines" string="Have been corrected" type="object" icon="terp-mail-" attrs="{'invisible': [('is_corrected', '=', False)]}"/>
181 <field name="product_id"
182 attrs="{'readonly': ['|',
183 '&amp;', ('invoice_type', '=', 'in_invoice'), '|', ('line_synced', '=', True), ('from_supply', '=', True),
184@@ -224,7 +254,13 @@
185 domain="[('journal_id', '=', parent.journal_id), ('restricted_area', '=', 'invoice_lines')]"
186 />
187 <field name="invoice_line_tax_id" view_mode="2" context="{'type':parent.type}" domain="[('parent_id','=',False)]"/>
188- <field domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
189+ <field name="inactive_product" invisible="1" />
190+ <button name="button_analytic_distribution" string="Analytical Distribution" type="object" icon="terp-stock_symbol-selection" context="context" attrs="{'invisible': [('is_allocatable', '=', False)]}"/>
191+ <field name="analytic_distribution_state_recap"/>
192+ <field name="have_analytic_distribution_from_header" invisible="1"/>
193+ <field name="analytic_distribution_state" invisible="1"/>
194+ <field name="is_allocatable" invisible="1"/>
195+
196 <field name="quantity"
197 attrs="{'readonly': ['|',
198 '&amp;', ('invoice_type', '=', 'in_invoice'), '|', ('line_synced', '=', True),('from_supply', '=', True),
199@@ -240,7 +276,9 @@
200 </tree>
201 </field>
202 <group col="1" colspan="2">
203- <field name="tax_line" nolabel="1" attrs="{'invisible': [('vat_ok', '=', False)], 'readonly': ['|', ('state','!=', 'draft'), '&amp;', ('type', '=', 'in_invoice'), ('synced', '=', True)]}">
204+ <field name="tax_line" nolabel="1"
205+ attrs="{'invisible': ['|', ('vat_ok', '=', False), ('doc_type', 'in', ('isi', 'isr'))],
206+ 'readonly': ['|', ('state','!=', 'draft'), '&amp;', ('type', '=', 'in_invoice'), ('synced', '=', True)]}">
207 <tree editable="bottom" string="Taxes">
208 <field name="invoice_id" invisible="True"/>
209 <field name="account_tax_id" on_change="tax_code_change(account_tax_id, parent.amount_untaxed, parent.partner_id, context)"/>
210@@ -265,24 +303,66 @@
211 </field>
212 </group>
213 <group col="4" colspan="2">
214- <button colspan="2" name="button_reset_taxes" states="draft" string="Compute Taxes" type="object" icon="terp-stock_format-scientific"/>
215- <field name="amount_untaxed"/>
216+ <button colspan="2" name="button_reset_taxes" states="draft" string="Compute Taxes"
217+ type="object" icon="terp-stock_format-scientific"
218+ attrs="{'invisible': ['|', ('vat_ok', '=', False), ('doc_type', 'in', ('isi', 'isr'))],
219+ 'readonly': [('state', '!=', 'draft')]}"/>
220+ <field name="amount_untaxed" attrs="{'invisible': ['|', ('vat_ok', '=', False), ('doc_type', 'in', ('isi', 'isr'))]}"/>
221 <label string="" colspan="2"/>
222- <field name="amount_tax"/>
223+ <field name="amount_tax" attrs="{'invisible': ['|', ('vat_ok', '=', False), ('doc_type', 'in', ('isi', 'isr'))]}" />
224 <field name="reconciled"/>
225 <field name="amount_total"/>
226 <field name="state"/>
227 <field name="residual"/>
228 <group col="6" colspan="4">
229- <button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="terp-stock_effects-object-colorize"/>
230- <button name="%(action_account_invoice_refund)d" type='action' string='Refund' states='open,paid,inv_close' icon="gtk-execute"/>
231- <button name="invoice_open" states="draft,proforma2" string="Approve" icon="terp-camera_test"/>
232+ <field name="doc_type" invisible="1"/>
233+ <button name="%(account.action_account_invoice_refund)d" type='action' string='Refund' icon="gtk-execute"
234+ attrs="{'invisible': ['|', '|',
235+ ('state', '=', 'draft'),
236+ ('type', 'in', ['in_refund', 'out_refund']),
237+ '&amp;', ('doc_type', '=', 'isi'), ('counterpart_inv_status', '!=', 'inv_close')]}"
238+ />
239+ <group attrs="{'invisible': [('doc_type', 'in', ('isi', 'isr'))]}">
240+ <button name="invoice_open" states="draft,proforma2" type="object" string="Validate" icon="gtk-go-forward"/>
241+ <field name="is_direct_invoice" invisible="1"/>
242+ <button name="button_split_invoice" states="draft,proforma2" type="object" string="Split Invoice" icon="gtk-cut"/>
243+ <newline/>
244+ <field name="can_merge_lines" invisible="1"/>
245+ <button name="button_merge_lines" type="object"
246+ colspan="3"
247+ string="Merge Lines by Account" icon="gtk-convert"
248+ confirm="You are about to merge invoice lines; are you sure you want to proceed? THIS OPERATION CAN NOT BE UNDONE."
249+ attrs="{'invisible': [('can_merge_lines', '!=', True)]}"/>
250+ </group>
251+
252 </group>
253 </group>
254+ <!-- for ISI/STR the display of the buttons takes the whole width -->
255+ <group col="8" colspan="6" attrs="{'invisible': [('doc_type', 'not in', ('isi', 'isr'))]}">
256+ <button name="button_merge_lines2" type="object"
257+ string="Merge Lines by Account"
258+ icon="gtk-convert" colspan="2"
259+ confirm="You are about to merge invoice lines; are you sure you want to proceed? THIS OPERATION CAN NOT BE UNDONE."
260+ attrs="{'invisible': [('can_merge_lines', '!=', True)]}"
261+ />
262+ <button name="button_split_invoice2" type="object"
263+ string="Split Invoice"
264+ icon="gtk-cut" colspan="2"
265+ states="draft"
266+ />
267+ <button name="invoice_open2" type="object"
268+ string="Validate"
269+ icon="gtk-go-forward" colspan="4"
270+ states="draft"
271+ />
272+ </group>
273 </page>
274 <page string="Other Info">
275+ <field name="amount_to_pay"/>
276 <field domain="[('partner_id', '=', partner_id)]" name="partner_bank_id" on_change="onchange_partner_bank(partner_bank_id)"/>
277- <field name="company_id" on_change="onchange_company_id(company_id,partner_id,type,invoice_line,currency_id)" widget="selection" groups="base.group_multi_company"/>
278+ <field name="company_id"
279+ on_change="onchange_company_id(company_id, partner_id, type, invoice_line, currency_id, context)"
280+ widget="selection" groups="base.group_multi_company"/>
281 <newline/>
282 <field name="payment_term" widget="selection"/>
283 <field name="name"
284@@ -304,6 +384,31 @@
285 <field colspan="4" name="comment" nolabel="1"/>
286 </page>
287 &payment_tab;
288+ <page string="Down Payments">
289+ <field name="down_payment_ids" nolabel="1" colspan="4">
290+ <tree string="Down Payment">
291+ <field name="move_id"/>
292+ <field name="name" string="Description"/>
293+ <field name="ref"/>
294+ <field name="date"/>
295+ <field name="partner_type"/>
296+ <field name="reconcile_txt"/>
297+ <field name="debit_currency"/>
298+ <field name="credit_currency"/>
299+ <field name="amount_currency" sum="Total Amount"/>
300+ <field name="currency_id"/>
301+ </tree>
302+ </field>
303+ </page>
304+ <!-- display the Counterpart Invoice tab in SI, hide it in SR -->
305+ <page string="Counterpart Invoice" attrs="{'invisible': [('type', '!=', 'in_invoice')]}">
306+ <field name="from_supply" invisible="1"/> <!-- make the field exportable -->
307+ <field name="synced" readonly="1"/> <!-- SI can never be ticked as "Synced" manually -->
308+ <newline/>
309+ <field name="counterpart_inv_number"/>
310+ <field name="counterpart_inv_status"/>
311+ </page>
312+
313 </notebook>
314 </form>
315 </field>
316@@ -314,38 +419,46 @@
317 <field name="model">account.invoice</field>
318 <field name="type">form</field>
319 <field name="arch" type="xml">
320- <form string="Invoice" noteditable="state=='cancel'">
321+ <form string="Stock Transfer Voucher" noteditable="state=='cancel'">
322 <group colspan="4" col="8">
323- <field name="journal_id" groups="base.group_user" widget="selection"/>
324- <field name="journal_type" invisible="1"/>
325- <field name="number"/>
326- <field name="type" invisible="1"/>
327- <field name="is_intermission" invisible="1"/> <!-- for Payment tab -->
328- <field name="currency_id" width="50"/>
329- <button name="%(action_account_change_currency)d" type="action" icon="terp-stock_effects-object-colorize" string="Change" attrs="{'invisible':[('state','!=','draft')]}" groups="account.group_account_user"/>
330- <newline/>
331- <field string="Customer" name="partner_id"
332- domain="[('customer', '=', True)]"
333- on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)"
334- groups="base.group_user" context="{'search_default_customer': 1}"
335- attrs="{'readonly': ['|',
336- ('state', '!=', 'draft'),
337- '&amp;', '&amp;',
338- ('type', '=', 'out_invoice'),
339- ('from_supply', '=', True),
340- ('partner_type', 'in', ('intermission', 'section'))]}"/>
341- <field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
342- <field name="fiscal_position" groups="base.group_extended" widget="selection"/>
343- <newline/>
344- <field name="date_invoice"/>
345- <field name="period_id" domain="[('state', '=', 'draft')]" groups="account.group_account_user" widget="selection"/>
346- <group colspan="2" col="1" groups="account.group_account_user">
347- <label align="0.0" string="(keep empty to use the current period)"/>
348- </group>
349- </group>
350+ <field name="journal_id" domain="[('inv_doc_type', '=', True)]"/>
351+ <field name="journal_type" invisible="1"/>
352+ <field name="number"/>
353+ <field name="type" invisible="1"/>
354+ <field name="is_intermission" invisible="1"/> <!-- for Payment tab -->
355+ <field name="currency_id" width="50"/>
356+ <button name="%(action_account_change_currency)d" type="action" icon="terp-stock_effects-object-colorize" string="Change" attrs="{'invisible':[('state','!=','draft')]}" groups="account.group_account_user"/>
357+ <newline/>
358+ <field string="Customer" name="partner_id"
359+ domain="[('customer', '=', True)]"
360+ on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)"
361+ groups="base.group_user" context="{'search_default_customer': 1}"
362+ attrs="{'readonly': ['|',
363+ ('state', '!=', 'draft'),
364+ '&amp;', '&amp;',
365+ ('type', '=', 'out_invoice'),
366+ ('from_supply', '=', True),
367+ ('partner_type', 'in', ('intermission', 'section'))]}"/>
368+ <field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
369+ <newline/>
370+ <field name="document_date"/>
371+ <field name="date_invoice"/>
372+ <group colspan="2" col="1" groups="account.group_account_user">
373+ </group>
374+ </group>
375+ <group colspan="4" col="8" attrs="{'invisible': [('analytic_distribution_id', '=', False)]}">
376+ <button name="button_analytic_distribution" string="Analytical Distribution" type="object" icon="terp-check" context="context" colspan="4" attrs="{'invisible': [('analytic_distribution_id', '=', False)]}"/>
377+ <button name="button_reset_distribution" string="Reset AD at line level" type="object" icon="gtk-undelete" colspan="4" states="draft"/>
378+ </group>
379+ <group colspan="4" col="8" attrs="{'invisible': [('analytic_distribution_id', '!=', False)]}">
380+ <button name="button_analytic_distribution" string="Analytical Distribution" type="object" icon="terp-emblem-important" context="context" colspan="4" attrs="{'invisible': [('analytic_distribution_id', '!=', False)]}"/>
381+ <button name="button_reset_distribution" string="Reset AD at line level" type="object" icon="gtk-undelete" colspan="4" states="draft"/>
382+ </group>
383+ <field name="analytic_distribution_id" invisible="1"/>
384+ <group colspan="3"/>
385 <notebook colspan="4">
386 <page string="Invoice">
387- <field domain="[('company_id', '=', company_id),('type','=', 'receivable')]" name="account_id" groups="account.group_account_user"/>
388+ <field domain="[('company_id', '=', company_id), ('restricted_area', '=', 'out_invoice')]" name="account_id" />
389 <field name="name" attrs="{'readonly': ['|',
390 ('state', '!=', 'draft'),
391 '&amp;', '&amp;',
392@@ -353,6 +466,21 @@
393 ('from_supply', '=', True),
394 ('partner_type', 'in', ('intermission', 'section'))]}"/>
395 <field name="payment_term" widget="selection"/>
396+ <group name="import" string=" Import Lines " colspan="4" col="4"
397+ attrs="{'invisible': [('state', '!=', 'draft'), ('type', '!=', 'out_invoice')]}">
398+ <button name="import_invoice" string="Import Invoice Line" icon="gtk-execute" colspan="2" type="object"
399+ attrs="{'readonly': [('state', '!=', 'draft')],
400+ 'invisible': [('type', '!=', 'out_invoice')]}"/>
401+ <button name="export_invoice" string="Export Invoice Line" icon="gtk-execute" colspan="2" type="object"
402+ attrs="{'invisible': [('type', '!=', 'out_invoice')]}"
403+ force_editable="1"/>
404+ <newline/>
405+ <button name="wizard_import_si_line" string="Import lines" icon="gtk-dnd" colspan="4" type="object"
406+ attrs="{'invisible': [('state', '!=', 'draft')],
407+ 'readonly': [('type', '=', 'out_invoice'),
408+ ('from_supply', '=', True),
409+ ('partner_type', 'in', ('intermission', 'section'))]}"/>
410+ </group>
411 <field colspan="4" name="invoice_line" nolabel="1" context="{'fake': 1, 'from_inv_form': True}">
412 <tree string="Invoice Line"
413 colors="red:inactive_product == True or analytic_distribution_state in ('invalid', 'invalid_small_amount');blue:inactive_product == False and analytic_distribution_state in ('valid');black:inactive_product == False and analytic_distribution_state in ('none')"
414@@ -397,44 +525,66 @@
415 <field name="name"/>
416 </tree>
417 </field>
418- <group col="1" colspan="2">
419- <field name="tax_line" nolabel="1">
420- <tree editable="bottom" string="Taxes">
421- <field name="name"/>
422- <field name="account_id" groups="account.group_account_invoice"/>
423- <field name="base"
424- on_change="base_change(base, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)"
425- readonly="1"/>
426- <field name="amount"
427- on_change="amount_change(amount, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)"/>
428- <field invisible="True" name="base_amount"/>
429- <field invisible="True" name="tax_amount"/>
430- <field name="factor_base" invisible="True"/>
431- <field name="factor_tax" invisible="True"/>
432- </tree>
433- </field>
434- </group>
435- <group col="4" colspan="2">
436- <button colspan="2" name="button_reset_taxes" states="draft" string="Compute Taxes" type="object" groups="base.group_user" icon="terp-stock_format-scientific"/>
437- <field name="amount_untaxed"/>
438- <label string="" colspan="2"/>
439- <field name="amount_tax"/>
440+ <group col="1" colspan="2" />
441+ <group col="8" colspan="4">
442+ <label string="" colspan="3"/>
443 <field name="reconciled"/>
444 <field name="amount_total"/>
445+ <label string="" colspan="3"/>
446 <field name="state"/>
447 <field name="residual"/>
448- <group col="8" colspan="4" groups="base.group_user">
449- <button name="action_cancel_draft" states="cancel" string="Reset to Draft" type="object" icon="terp-stock_effects-object-colorize"/>
450-
451- <button name="%(action_account_invoice_refund)d" type='action' string='Refund' states='open,paid,inv_close' icon="gtk-execute"/>
452- <button name="invoice_proforma2" states="draft" string="PRO-FORMA" icon="terp-gtk-media-pause" groups="account.group_account_user"/>
453- <button name="invoice_open" states="draft,proforma2" string="Validate" icon="gtk-go-forward"/>
454- <button name="%(account_invoices)d" string="Print Invoice" type="action" icon="gtk-print" states="open,paid,inv_close,proforma,sale,proforma2"/>
455- </group>
456+ <field name="is_debit_note" invisible="1"/>
457+ </group>
458+ <field name="partner_type" invisible="1"/>
459+ <group col="8" colspan="4">
460+
461+ <field name="doc_type" invisible="1"/>
462+
463+ <button string="Cancel document" name="invoice_cancel"
464+ type="workflow" icon="gtk-cancel"
465+ confirm="Do you really want to cancel this document?"
466+ attrs="{'invisible': ['|', '|',
467+ ('state', '!=', 'draft'),
468+ ('type', '!=', 'out_invoice'),
469+ ('from_supply', '=', False)]}"/>
470+
471+ <button name="button_split_invoice" type="object" string="Split Stock Transfer Voucher"
472+ icon="gtk-cut"
473+ context="{'from_stv': True}"
474+ attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('doc_type', '!=', 'stv')]}"/>
475+
476+ <button name="%(account.action_account_invoice_refund)d" type='action' string='Refund' icon="gtk-execute" attrs="{'invisible': ['|', ('state', 'in', ['draft']), ('type', 'in', ['in_refund', 'out_refund'])]}"/>
477+ <!-- add a confirmation step only for STV (not for CR/STR)
478+ when the partner type is compatible with a synchro but "synced" isn't ticked -->
479+ <button name="invoice_open" type="object" string="Validate"
480+ icon="gtk-go-forward"
481+ attrs="{'invisible': ['|',
482+ ('state', '!=', 'draft'),
483+ '&amp;',
484+ ('doc_type', '=', 'stv'), ('partner_type', 'in', ('intermission', 'section')) ]}"/>
485+ <button name="invoice_open_with_confirmation" type="object" string="Validate"
486+ icon="gtk-go-forward"
487+ confirm="Are you sure you want to validate this invoice without synchronization?"
488+ attrs="{'invisible': ['|', '|', '|',
489+ ('state', '!=', 'draft'),
490+ ('doc_type', '!=', 'stv'),
491+ ('synced', '=', True),
492+ ('partner_type', 'not in', ('intermission', 'section'))]}"/>
493+
494+ <button name="invoice_open_with_sync_confirmation" type="object" string="Validate"
495+ icon="gtk-go-forward"
496+ confirm="This invoice will sync to its counterpart instance."
497+ attrs="{'invisible': ['|', '|', '|',
498+ ('state', '!=', 'draft'),
499+ ('doc_type', '!=', 'stv'),
500+ ('synced', '=', False),
501+ ('partner_type', 'not in', ('intermission', 'section'))]}"/>
502+ <button name="%(account.account_invoices)d" string="Print Invoice" type="action" icon="gtk-print" states="open,paid,inv_close,proforma,sale,proforma2"/>
503 </group>
504 </page>
505 <page string="Other Info">
506- <field name="company_id" on_change="onchange_company_id(company_id,partner_id,type,invoice_line,currency_id)" widget="selection" groups="base.group_multi_company"/>
507+ <field name="company_id" on_change="onchange_company_id(company_id, partner_id, type, invoice_line, currency_id, context)"
508+ widget="selection" groups="base.group_multi_company"/>
509 <newline/>
510 <field name="date_due"/>
511 <field name="user_id" attrs="{'readonly': ['|',
512@@ -461,7 +611,7 @@
513 <field colspan="4" name="comment" nolabel="1"/>
514 </page>
515 &payment_tab;
516- <!-- display the Counterpart Invoice tab in STV, hide it in Customer Refunds -->
517+ <!-- display the Counterpart Invoice tab in STV, hide it in CR/STR -->
518 <page string="Counterpart Invoice" attrs="{'invisible': [('type', '!=', 'out_invoice')]}">
519 <field name="from_supply" invisible="1"/>
520 <field name="synced"
521@@ -484,16 +634,19 @@
522 <search string="Search Invoice">
523 <group col="10" colspan="4">
524 <filter name="draft" icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Invoices"/>
525- <filter name="proforma" icon="terp-gtk-media-pause" string="Proforma" domain="[('state','=','proforma2')]" help="Proforma Invoices"/>
526- <filter name="invoices" icon="terp-dolar" string="Invoices" domain="[('state','not in',['draft','cancel'])]" help="Proforma/Open/Paid Invoices"/>
527- <separator orientation="vertical"/>
528- <filter name="unpaid" icon="terp-dolar_ok!" string="Unpaid" domain="[('state','=','open')]" help="Unpaid Invoices"/>
529+ <filter name="unpaid" icon="terp-dolar_ok!" string="Open" domain="[('state','=','open')]" help="Open Invoices"/>
530+ <filter name="paid" icon="terp-dolar" string="Paid" domain="[('state', '=', 'paid')]"/>
531+ <filter name="closed" icon="terp-dialog-close" string="Closed" domain="[('state', '=', 'inv_close')]" />
532+ <filter name="cancel_state" icon="terp-gtk-stop" string="Cancelled" domain="[('state', '=', 'cancel')]"/>
533+ <separator orientation="vertical"/>
534+ <filter name="not_imported" icon="gtk-cancel" string="Not imported" domain="[('imported_state', '=', 'not')]"/>
535+ <filter name="partial" icon="terp-dolar_ok!" string="Partially imported" domain="[('imported_state', '=', 'partial')]"/>
536+ <filter name="imported" icon="gtk-apply" string="Imported" domain="[('imported_state', '=', 'imported')]"/>
537+ <separator orientation="vertical"/>
538+
539 <separator orientation="vertical"/>
540 <field name="number"/>
541 <field name="partner_id"/>
542- <field name="user_id" select="1" widget="selection" string="Salesman">
543- <filter domain="[('user_id','=',uid)]" help="My invoices" icon="terp-personal" separator="1"/>
544- </field>
545 <field name="origin"/>
546 <field name="amount_total"/>
547 </group>
548@@ -501,11 +654,12 @@
549 <group col="10" colspan="4">
550 <field name="journal_id" widget="selection" select='1'/>
551 <field name="period_id" select='1' string="Period" domain="[('state', 'not in', ['done', 'created'])]"/>
552+ <field name="supplier_reference"/>
553+ <field name="name"/>
554 </group>
555 <newline/>
556 <group expand="0" string="Group By...">
557 <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
558- <filter string="Responsible" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
559 <separator orientation="vertical"/>
560 <filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
561 <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
562@@ -552,15 +706,16 @@
563 <field name="act_window_id" ref="action_invoice_tree"/>
564 </record>
565
566- <record id="action_invoice_tree1" model="ir.actions.act_window">
567- <field name="name">Customer Invoices</field>
568+ <!-- Fix customer invoice display with a bypass on 'is_debit_note' set to True -->
569+ <record id="account.action_invoice_tree1" model="ir.actions.act_window">
570+ <field name="name">Customer Invoices</field> <!-- Stock Transfer Vouchers -->
571 <field name="res_model">account.invoice</field>
572 <field name="view_type">form</field>
573 <field name="view_mode">tree,form,calendar,graph</field>
574 <field eval="False" name="view_id"/>
575- <field name="domain">[('type','=','out_invoice')]</field>
576- <field name="context">{'type':'out_invoice', 'journal_type': 'sale'}</field>
577- <field name="search_view_id" ref="view_account_invoice_filter"/>
578+ <field name="domain">[('doc_type', '=', 'stv')]</field>
579+ <field name="context">{'doc_type': 'stv', 'type': 'out_invoice', 'journal_type': 'sale', 'from_inv_form': True, 'search_default_draft': 1, 'search_default_unpaid': 1, 'search_default_paid': 1, 'search_default_closed': 1}</field>
580+ <field name="search_view_id" ref="account.view_account_invoice_filter"/>
581 <field name="help">With Customer Invoices you can create and manage sales invoices issued to your customers. OpenERP can also generate draft invoices automatically from sales orders or deliveries. You should only confirm them before sending them to your customers.</field>
582 </record>
583
584@@ -578,20 +733,26 @@
585 <field name="act_window_id" ref="action_invoice_tree1"/>
586 </record>
587
588- <menuitem action="action_invoice_tree1" id="menu_action_invoice_tree1" parent="menu_finance_receivables"/>
589+ <!-- STV -->
590+ <menuitem action="action_invoice_tree1" id="menu_action_invoice_tree1" parent="menu_finance_receivables" sequence="3"/>
591
592- <record id="action_invoice_tree2" model="ir.actions.act_window">
593+ <!-- Fix supplier invoice display with a bypass on 'is_inkind_donation' set to True -->
594+ <record id="account.action_invoice_tree2" model="ir.actions.act_window">
595 <field name="name">Supplier Invoices</field>
596 <field name="res_model">account.invoice</field>
597 <field name="view_type">form</field>
598 <field name="view_mode">tree,form,calendar,graph</field>
599 <field eval="False" name="view_id"/>
600- <field name="domain">[('type','=','in_invoice')]</field>
601- <field name="context">{'type':'in_invoice', 'journal_type': 'purchase'}</field>
602- <field name="search_view_id" ref="view_account_invoice_filter"/>
603- <field name="help">With Supplier Invoices you can enter and manage invoices issued by your suppliers. OpenERP can also generate draft invoices automatically from purchase orders or receipts. This way, you can control the invoice from your supplier according to what you purchased or received.</field>
604+ <!-- US-2704 if the domain change, do not forget to update the domain of account_board_supplier_invoice_draft in finance/board_account_view.xml -->
605+ <field name="domain">[('doc_type', '=', 'si')]</field>
606+ <field name="context">{'doc_type': 'si', 'type': 'in_invoice', 'journal_type': 'purchase', 'from_inv_form': True}</field>
607+ <field name="search_view_id" ref="account.view_account_invoice_filter"/>
608+ <field name="help">With Supplier Invoices you can enter and manage invoices issued by your suppliers.
609+ OpenERP can also generate draft invoices automatically from purchase orders or receipts. This way, you can control the invoice
610+ from your supplier according to what you purchased or received.</field>
611 </record>
612- <menuitem action="action_invoice_tree2" id="menu_action_invoice_tree2" parent="menu_finance_payables"/>
613+
614+ <menuitem action="action_invoice_tree2" id="menu_action_invoice_tree2" parent="menu_finance_payables" sequence="10"/>
615
616 <record id="action_invoice_tree3" model="ir.actions.act_window">
617 <field name="name">Customer Refunds</field>
618@@ -599,8 +760,8 @@
619 <field name="view_type">form</field>
620 <field name="view_mode">tree,form,calendar,graph</field>
621 <field eval="False" name="view_id"/>
622- <field name="domain">[('type','=','out_refund')]</field>
623- <field name="context">{'type':'out_refund', 'journal_type': 'sale_refund'}</field>
624+ <field name="domain">[('doc_type', '=', 'cr')]</field>
625+ <field name="context">{'doc_type': 'cr', 'type': 'out_refund', 'journal_type': 'sale_refund'}</field>
626 <field name="search_view_id" ref="view_account_invoice_filter"/>
627 <field name="help">With Customer Refunds you can manage the credit notes for your customers. A refund is a document that credits an invoice completely or partially. You can easily generate refunds and reconcile them directly from the invoice form.</field>
628 </record>
629@@ -617,7 +778,8 @@
630 <field name="view_id" ref="invoice_form"/>
631 <field name="act_window_id" ref="action_invoice_tree3"/>
632 </record>
633- <menuitem action="action_invoice_tree3" id="menu_action_invoice_tree3" parent="menu_finance_receivables"/>
634+ <!-- Customer Refunds Menu -->
635+ <menuitem action="action_invoice_tree3" id="menu_action_invoice_tree3" parent="menu_finance_receivables" sequence="6"/>
636
637 <record id="action_invoice_tree4" model="ir.actions.act_window">
638 <field name="name">Supplier Refunds</field>
639@@ -625,14 +787,40 @@
640 <field name="view_type">form</field>
641 <field name="view_mode">tree,form,calendar,graph</field>
642 <field eval="False" name="view_id"/>
643- <field name="domain">[('type','=','in_refund')]</field>
644- <field name="context">{'type':'in_refund', 'journal_type': 'purchase_refund'}</field>
645+ <field name="domain">[('doc_type', '=', 'sr')]</field>
646+ <field name="context">{'doc_type': 'sr', 'type': 'in_refund', 'journal_type': 'purchase_refund'}</field>
647 <field name="search_view_id" ref="view_account_invoice_filter"/>
648 <field name="help">With Supplier Refunds you can manage the credit notes you receive from your suppliers. A refund is a document that credits an invoice completely or partially. You can easily generate refunds and reconcile them directly from the invoice form.</field>
649 </record>
650- <menuitem action="action_invoice_tree4" id="menu_action_invoice_tree4" parent="menu_finance_payables"/>
651-
652- <act_window context="{'search_default_partner_id':[active_id]}" id="act_res_partner_2_account_invoice_opened" name="Invoices" res_model="account.invoice" src_model="res.partner"/>
653+ <menuitem action="action_invoice_tree4" id="menu_action_invoice_tree4" parent="menu_finance_payables" sequence="15"/>
654+
655+
656+ <record id="generic_invoice_tree" model="ir.ui.view">
657+ <field name="name">account.invoice.generic.tree</field>
658+ <field name="model">account.invoice</field>
659+ <field name="type">tree</field>
660+ <field name="priority" eval="100" />
661+ <field name="arch" type="xml">
662+ <tree colors="blue:state in ('draft');black:state in ('proforma','proforma2','open');gray:state in ('cancel')" string="Invoice" hide_new_button="1" hide_edit_button="1" hide_delete_button="1">
663+ <button name="invoice_open_form_view" string="Display Invoice" icon="gtk-go-forward" type="object"/>
664+ <field name="doc_type"/>
665+ <field name="date_invoice"/>
666+ <field name="number"/>
667+ <field name="partner_id"/>
668+ <field name="name"/>
669+ <field name="date_due"/>
670+ <field name="origin"/>
671+ <field name="line_count"/>
672+ <field name="currency_id"/>
673+ <field name="residual" sum="Residual Amount"/>
674+ <field name="amount_untaxed" sum="Untaxed Amount"/>
675+ <field name="amount_total" sum="Total Amount"/>
676+ <field name="state"/>
677+ </tree>
678+ </field>
679+ </record>
680+ <act_window context="{'search_default_partner_id': [active_id], 'generic_invoice': True}" id="act_res_partner_2_account_invoice_opened" name="Invoices" res_model="account.invoice" src_model="res.partner" view_id="generic_invoice_tree" view_mode="tree" search_view_id="view_account_invoice_filter"/>
681+
682
683 <act_window
684 id="act_account_journal_2_account_invoice_opened"
685@@ -641,5 +829,80 @@
686 res_model="account.invoice"
687 src_model="account.journal"/>
688
689+ <!-- STOCK TRANSFER REFUNDS -->
690+ <record id="action_str" model="ir.actions.act_window">
691+ <field name="name">Stock Transfer Refunds</field>
692+ <field name="res_model">account.invoice</field>
693+ <field name="view_type">form</field>
694+ <field name="view_mode">tree,form,calendar,graph</field>
695+ <field eval="False" name="view_id"/>
696+ <field name="domain">[('doc_type', '=', 'str')]</field>
697+ <field name="context">{'doc_type': 'str', 'type': 'out_refund', 'from_inv_form': True}</field>
698+ <field name="search_view_id" ref="view_account_invoice_filter"/> <!-- as for Customer Refunds -->
699+ </record>
700+ <record id="action_str_tree" model="ir.actions.act_window.view">
701+ <field eval="30" name="sequence"/>
702+ <field name="view_mode">tree</field>
703+ <field name="view_id" ref="invoice_tree"/> <!-- as for Customer Refunds (default tree view) -->
704+ <field name="act_window_id" ref="action_str"/>
705+ </record>
706+ <record id="action_str_form" model="ir.actions.act_window.view">
707+ <field eval="35" name="sequence"/>
708+ <field name="view_mode">form</field>
709+ <field name="view_id" ref="invoice_form"/> <!-- as for Customer Refunds -->
710+ <field name="act_window_id" ref="action_str"/>
711+ </record>
712+ <menuitem action="action_str" id="menu_action_str" parent="menu_finance_receivables" sequence="4"/>
713+
714+ <!-- INTERSECTION SUPPLIER INVOICES -->
715+ <record id="action_isi" model="ir.actions.act_window">
716+ <field name="name">Intersection Supplier Invoices</field>
717+ <field name="res_model">account.invoice</field>
718+ <field name="view_type">form</field>
719+ <field name="view_mode">tree,form,calendar,graph</field>
720+ <field eval="False" name="view_id"/>
721+ <field name="domain">[('doc_type', '=', 'isi')]</field>
722+ <field name="context">{'doc_type': 'isi', 'type': 'in_invoice', 'from_inv_form': True}</field>
723+ <field name="search_view_id" ref="view_account_invoice_filter"/> <!-- as for Supplier Invoices -->
724+ </record>
725+ <record id="action_isi_tree" model="ir.actions.act_window.view">
726+ <field eval="40" name="sequence"/>
727+ <field name="view_mode">tree</field>
728+ <field name="view_id" ref="invoice_tree"/> <!-- default tree view -->
729+ <field name="act_window_id" ref="action_isi"/>
730+ </record>
731+ <record id="action_isi_form" model="ir.actions.act_window.view">
732+ <field eval="45" name="sequence"/>
733+ <field name="view_mode">form</field>
734+ <field name="view_id" ref="invoice_supplier_form"/>
735+ <field name="act_window_id" ref="action_isi"/>
736+ </record>
737+ <menuitem action="action_isi" id="menu_action_isi" parent="menu_finance_payables" sequence="20"/>
738+
739+ <!-- INTERSECTION SUPPLIER REFUNDS -->
740+ <record id="action_isr" model="ir.actions.act_window">
741+ <field name="name">Intersection Supplier Refunds</field>
742+ <field name="res_model">account.invoice</field>
743+ <field name="view_type">form</field>
744+ <field name="view_mode">tree,form,calendar,graph</field>
745+ <field eval="False" name="view_id"/>
746+ <field name="domain">[('doc_type', '=', 'isr')]</field>
747+ <field name="context">{'doc_type': 'isr', 'type': 'in_refund', 'from_inv_form': True}</field>
748+ <field name="search_view_id" ref="view_account_invoice_filter"/> <!-- as for Supplier Refunds -->
749+ </record>
750+ <record id="action_isr_tree" model="ir.actions.act_window.view">
751+ <field eval="50" name="sequence"/>
752+ <field name="view_mode">tree</field>
753+ <field name="view_id" ref="invoice_tree"/> <!-- default tree view -->
754+ <field name="act_window_id" ref="action_isr"/>
755+ </record>
756+ <record id="action_isr_form" model="ir.actions.act_window.view">
757+ <field eval="55" name="sequence"/>
758+ <field name="view_mode">form</field>
759+ <field name="view_id" ref="invoice_supplier_form"/>
760+ <field name="act_window_id" ref="action_isr"/>
761+ </record>
762+ <menuitem action="action_isr" id="menu_action_isr" parent="menu_finance_payables" sequence="22"/>
763+
764 </data>
765 </openerp>
766
767=== modified file 'bin/addons/account/account_menuitem.xml'
768--- bin/addons/account/account_menuitem.xml 2017-04-13 14:08:16 +0000
769+++ bin/addons/account/account_menuitem.xml 2021-11-03 13:33:55 +0000
770@@ -8,7 +8,7 @@
771 web_icon_hover="images/accounting-hover.png"/>
772 <menuitem id="menu_finance_receivables" name="Customers" parent="menu_finance" sequence="2"/>
773 <menuitem id="menu_finance_payables" name="Suppliers" parent="menu_finance" sequence="3"/>
774- <menuitem id="menu_finance_bank_and_cash" name="Bank and Cash" parent="menu_finance" sequence="4"
775+ <menuitem id="account.menu_finance_bank_and_cash" name="Registers" parent="account.menu_finance" sequence="1" />
776 groups="group_account_user,group_account_manager"/>
777 <menuitem id="menu_finance_periodical_processing" name="Periodical Processing" parent="menu_finance" sequence="9" groups="group_account_user,group_account_manager"/>
778 <!-- This menu is used in account_code module -->
779
780=== modified file 'bin/addons/account/account_view.xml'
781--- bin/addons/account/account_view.xml 2020-10-28 13:59:22 +0000
782+++ bin/addons/account/account_view.xml 2021-11-03 13:33:55 +0000
783@@ -167,35 +167,89 @@
784 <field name="arch" type="xml">
785 <form string="Account">
786 <group col="6" colspan="4">
787- <field name="name" select="1"/>
788- <field name="code" select="1"/>
789- <field name="company_id" widget="selection" groups="base.group_multi_company"/>
790- <newline/>
791- <field name="parent_id"/>
792- <field name="type" select="1"/>
793- <field name="user_type" select="1"/>
794+ <field name="name" select="1"/>
795+ <field name="code" select="1"/>
796+ <newline/>
797+ <field name="parent_id"/>
798+ <field name="type" select="1"/>
799+ <field name="user_type_code" invisible="1"/>
800+ <field name="is_analytic_addicted" invisible="1"/>
801+ <field name="user_type" on_change="onchange_user_type(user_type, code)"/>
802+ <field name="shrink_entries_for_hq"/>
803+ <field name="is_child_of_coa" invisible="1" />
804+ <field name="display_in_reports" attrs="{'invisible': [('is_child_of_coa', '=', False)]}" />
805+ <field name="type_for_register"/>
806+ <field name="accrual_account" />
807+ <field name="is_not_hq_correctible" on_change="onchange_is_not_hq_correctible(is_not_hq_correctible)"/>
808+ <newline/>
809+ <label string="" colspan="2"/>
810+ <field name="is_not_ad_correctable" on_change="onchange_is_not_ad_correctable(is_not_ad_correctable)"/>
811 </group>
812 <notebook colspan="4">
813 <page string="General Information">
814- <field name="active" groups="base.group_extended" />
815- <newline/>
816- <group col="2" colspan="2">
817- <separator string="Currency" colspan="2"/>
818- <field name="currency_id"/>
819- <field name="currency_mode" attrs="{'readonly': [('currency_id','=',False)]}"/>
820- </group>
821- <group col="2" colspan="2">
822- <separator string="Reconcile" colspan="2"/>
823- <field name="reconcile"/>
824- </group>
825- <separator string="Default Taxes" colspan="4"/>
826- <field colspan="4" name="tax_ids" nolabel="1" domain="[('parent_id','=',False)]"/>
827- <separator string="Consolidated Children" colspan="4"/>
828- <field name="child_consol_ids" colspan="4" nolabel="1" attrs="{'readonly':[('type','!=','consolidation')]}"/>
829+ <group col="6" colspan="4">
830+ <field name="activation_date"/>
831+ <field name="inactivation_date"/>
832+ <group col="2" colspan="2">
833+ <field name="reconcile" on_change="onchange_reconcile(reconcile)"/>
834+ <field name="prevent_multi_curr_rec" attrs="{'readonly': [('reconcile', '=', False)]}"/>
835+ <field name="reconciliation_debit_account_id"/>
836+ <field name="reconciliation_credit_account_id"/>
837+ </group>
838+ </group>
839+ </page>
840+ <page string="Analytical Destination">
841+ <field name="default_destination_id" colspan="2"
842+ attrs="{'required': [('is_analytic_addicted', '=', True)], 'readonly': [('is_analytic_addicted', '!=', True)]}"/>
843+ <label string="" colspan="2"/>
844+ <field name="destination_ids" nolabel="1" colspan="4" domain="[('type', '!=', 'view'), ('category', '=', 'DEST')]">
845+ <tree string="Destinations">
846+ <field name="name"/>
847+ <field name="description"/>
848+ <field name="date_start"/>
849+ <field name="date"/>
850+ </tree>
851+ </field>
852+ </page>
853+ <page string="Allowed Partner types">
854+ <group col="4" colspan="4">
855+ <group col="2" colspan="2">
856+ <field name="has_partner_type_internal" />
857+ <field name="has_partner_type_external" />
858+ <field name="has_partner_type_esc" />
859+ <newline />
860+ <field name="has_partner_type_local" />
861+ <field name="has_partner_type_ex" />
862+ <field name="has_partner_type_empty" />
863+ <newline />
864+ <field name="has_partner_type_book" />
865+ </group>
866+
867+ <group col="2" colspan="2">
868+ <field name="has_partner_type_intermission" />
869+ <field name="has_partner_type_section" />
870+
871+ <label /><label />
872+ <newline />
873+ <label /><label />
874+ <label /><label />
875+ <newline />
876+ <label /><label />
877+ </group>
878+ </group>
879 </page>
880 <page string="Notes">
881 <field colspan="4" name="note" nolabel="1"/>
882 </page>
883+ <page string="Currency Revaluation" attrs="{'invisible': [('instance_level', '=', 'project')]}">
884+ <field name="instance_level" invisible="1"/>
885+ <field name="currency_revaluation"
886+ attrs="{'readonly': ['|', ('instance_level', '!=', 'section'), ('user_type_code', 'not in', ['receivables', 'payables', 'cash', 'asset', 'stock'])]}"/>
887+ </page>
888+ <page string="End Year Closing" attrs="{'invisible': [('instance_level', '=', 'project')]}">
889+ <field name="include_in_yearly_move"
890+ attrs="{'readonly': ['|', ('instance_level', '!=', 'section'), ('type', 'not in', ['other', ])]}"/>
891+ </page>
892 </notebook>
893 </form>
894 </field>
895@@ -290,26 +344,24 @@
896 </field>
897 </record>
898
899- <record id="view_account_list" model="ir.ui.view">
900- <field name="name">account.account.list</field>
901+ <!-- Tree view for default tree view of accounts -->
902+ <record id="account.view_account_list" model="ir.ui.view">
903+ <field name="name">account.account_activable.list</field>
904 <field name="model">account.account</field>
905 <field name="type">tree</field>
906 <field name="field_parent">child_id</field>
907+ <field name="priority" eval="10"/>
908 <field name="arch" type="xml">
909- <tree colors="blue:type in ('view');black:type in ('other','receivable','payable','consolidation');gray:type in ('closed')" string="Chart of accounts" toolbar="1" >
910+ <tree colors="blue:type in ('view');black:type in ('other','receivable','payable','consolidation');gray:type in ('closed')" string="Chart of accounts" toolbar="1" nolink="1">
911 <field name="code"/>
912 <field name="name"/>
913- <field name="parent_id" invisible="1"/>
914- <field name="user_type" invisible="1"/>
915- <field name="debit"/>
916- <field name="credit"/>
917- <field name="balance"/>
918 <field name="type"/>
919- <field name="company_id" groups="base.group_multi_company"/>
920- <field name="company_currency_id"/>
921+ <field name="activation_date"/>
922+ <field name="inactivation_date"/>
923 </tree>
924 </field>
925 </record>
926+
927 <record id="view_treasory_graph" model="ir.ui.view">
928 <field name="name">account.treasury.graph</field>
929 <field name="model">account.account</field>
930@@ -334,26 +386,29 @@
931 <menuitem id="account_account_menu" name="Accounts" parent="menu_finance_accounting"/>
932 <menuitem action="action_account_form" id="menu_action_account_form" parent="account_account_menu"/>
933
934- <record id="view_account_tree" model="ir.ui.view">
935- <field name="name">account.account.tree</field>
936+ <record model="ir.ui.view" id="account.view_account_tree">
937+ <field name="name">account.account_activable.tree</field>
938 <field name="model">account.account</field>
939 <field name="type">tree</field>
940 <field name="field_parent">child_id</field>
941- <field name="priority" eval="13"/>
942+ <field name="priority" eval="12"/>
943 <field name="arch" type="xml">
944- <tree colors="blue:type in ('view');black:type in ('other','receivable','payable','consolidation');gray:type in ('closed')" string="Chart of accounts" toolbar="1" >
945+ <tree colors="blue:type in ('view');black:type in ('other','receivable','payable','consolidation');gray:type in ('closed')" string="Chart of accounts" toolbar="1" expand_button="1" nolink="1">
946 <field name="code"/>
947 <field name="name"/>
948- <field name="debit"/>
949- <field name="credit"/>
950- <field name="balance"/>
951- <field name="company_currency_id"/>
952- <field name="company_id" groups="base.group_multi_company"/>
953- <field name="type"/>
954+ <field name="note"/>
955+ <field name="type" invisible="1"/>
956+ <field name="type_for_register" invisible="1"/>
957+ <field name="accrual_account" invisible="1"/>
958+ <field name="is_not_hq_correctible" invisible="1"/>
959+ <field name="activation_date" invisible="1"/>
960+ <field name="inactivation_date" invisible="1"/>
961 <field name="parent_id" invisible="1"/>
962+ <field name="is_analytic_addicted" invisible="1"/>
963 </tree>
964 </field>
965 </record>
966+
967 <record id="action_account_tree" model="ir.actions.act_window">
968 <field name="name">Chart of Accounts</field>
969 <field name="res_model">account.account</field>
970@@ -546,52 +601,84 @@
971 </record>
972 <menuitem action="action_account_journal_form" id="menu_action_account_journal_form" parent="menu_journals"/>
973
974- <record id="view_account_bank_statement_filter" model="ir.ui.view">
975+ <!-- Bank Statement Filter -->
976+ <record id="account.view_account_bank_statement_filter" model="ir.ui.view">
977 <field name="name">account.cash.statement.select</field>
978 <field name="model">account.bank.statement</field>
979 <field name="type">search</field>
980- <field name="priority" eval="18"/>
981 <field name="arch" type="xml">
982 <search string="Search Bank Statements">
983 <group col="8" colspan="4">
984- <filter string="Draft" domain="[('state','=','draft')]" icon="terp-document-new"/>
985- <filter string="Confirmed" domain="[('state','=','confirm')]" icon="terp-camera_test"/>
986+ <filter string="Draft" domain="[('state','=','draft')]" icon="terp-document-new" name="draft"/>
987+ <filter string="Open" domain="[('state', '=', 'open')]" icon="terp-camera_test" name="open"/>
988+ <filter string="Closed" domain="[('state','=','confirm')]" icon="terp-dialog-close" name="confirm"/>
989 <separator orientation="vertical"/>
990- <field name="date"/>
991+ <field name="instance_id" domain="[('instance_to_display_ids','=',True)]"/>
992 <field name="name"/>
993- <field name="journal_id" widget='selection' domain="[('type', '=', 'cash')]" />
994+ <newline/>
995+ <field name="period_id" domain="[('state', '!=', 'created')]"/>
996+ <field name="journal_id" domain="[('type', '=', 'cash')]" />
997 </group>
998 <newline/>
999- <group expand="0" string="Group By...">
1000+ <group expand="1" string="Group By...">
1001 <filter string="Journal" context="{'group_by': 'journal_id'}" icon="terp-folder-orange"/>
1002 <filter string="State" context="{'group_by': 'state'}" icon="terp-stock_effects-object-colorize"/>
1003 <separator orientation="vertical"/>
1004 <filter string="Period" context="{'group_by': 'period_id'}" icon="terp-go-month"/>
1005+ <filter string="Instance" context="{'group_by': 'instance_id'}" icon="terp-stage"/>
1006 </group>
1007 </search>
1008 </field>
1009 </record>
1010
1011- <record id="view_bank_statement_tree" model="ir.ui.view">
1012+
1013+ <!-- Bank Statement Tree US-807: force the priority to 10 to avoid showing the view in addons, for default tree view, check the view named account.view_bank_statement_tree_for_journal for more info -->
1014+ <record id="account.view_bank_statement_tree" model="ir.ui.view">
1015 <field name="name">account.bank.statement.tree</field>
1016 <field name="model">account.bank.statement</field>
1017 <field name="type">tree</field>
1018- <field name="priority" eval="19"/>
1019- <field name="arch" type="xml">
1020- <tree colors="red:balance_end_real!=balance_end and state=='draft';blue:state=='draft' and (balance_end_real==balance_end);black:state=='confirm'" string="Statement">
1021- <field name="name"/>
1022- <field name="date"/>
1023- <field name="period_id"/>
1024- <field name="journal_id"/>
1025- <field name="balance_start"/>
1026- <field name="balance_end_real"/>
1027- <field name="balance_end" invisible="1"/>
1028- <field name="state"/>
1029- <button type="object" string="Cancel" name="button_cancel" states="confirm" icon="gtk-cancel"/>
1030- <button type="object" string="Confirm" name="button_confirm_bank" states="draft" icon="terp-camera_test"/>
1031- </tree>
1032- </field>
1033- </record>
1034+ <field name="priority" eval="10"/>
1035+ <field name="arch" type="xml">
1036+ <tree colors="blue:state=='draft';black:state in ('open','confirm')" string="Register" hide_new_button="1" hide_delete_button="1">
1037+ <field name="name"/>
1038+ <field name="date"/>
1039+ <field name="period_id"/>
1040+ <field name="currency"/>
1041+ <field name="journal_id"/>
1042+ <field name="balance_start"/>
1043+ <field name="balance_end" />
1044+ <field name="balance_end_real"/>
1045+ <field name="state"/>
1046+ <button name="button_open_bank_register" states="draft" string="Open Bank" type="object" icon="terp-gtk-go-back-rtl"/>
1047+ <button name="button_confirm_bank" states="open" string="Close Register" type="object" icon="terp-camera_test"/>
1048+ </tree>
1049+ </field>
1050+ </record>
1051+
1052+ <!-- US-807: force the priority to 5 to show by default for all cases, BUT when the tree is called from Bank/Cash/Cheque main menu, then the explicit view name will be picked in the python code "register_accounting/account_bank_statement.py" method: get_statement() -->
1053+ <record id="account.view_bank_statement_tree_for_journal" model="ir.ui.view">
1054+ <field name="name">account.bank.statement.tree.journal</field>
1055+ <field name="model">account.bank.statement</field>
1056+ <field name="type">tree</field>
1057+ <field name="priority" eval="5"/>
1058+ <field name="arch" type="xml">
1059+ <tree colors="blue:state=='draft';black:state in ('open','confirm')" string="Register" hide_new_button="1" hide_delete_button="1" editable="bottom" noteditable="1">
1060+ <field name="name"/>
1061+ <field name="date"/>
1062+ <field name="period_id"/>
1063+ <field name="currency"/>
1064+ <field name="journal_id"/>
1065+ <field name="balance_start"/>
1066+ <field name="balance_end" />
1067+ <field name="balance_end_real"/>
1068+ <field name="state"/>
1069+ </tree>
1070+ </field>
1071+ </record>
1072+
1073+
1074+
1075+
1076 <record id="view_bank_statement_search" model="ir.ui.view">
1077 <field name="name">account.bank.statement.search</field>
1078 <field name="model">account.bank.statement</field>
1079@@ -1821,7 +1908,7 @@
1080 <filter icon="terp-camera_test" string="Running" name="running" domain="[('state', '=', 'running')]"/>
1081 <filter icon="terp-dialog-close" string="Done" name="done" domain="[('state', '=', 'done')]" />
1082 <field name="name"/>
1083- <field name="journal_id" domain="[('type', '=', 'purchase'), ('is_current_instance', '=', True)]"/>
1084+ <field name="journal_id" domain="[('type', '=', 'purchase'), ('code', '!=', 'ISI'), ('is_current_instance', '=', True)]"/>
1085 </group>
1086 <newline/>
1087 <group expand="0" string="Group By...">
1088
1089=== modified file 'bin/addons/account/invoice.py'
1090--- bin/addons/account/invoice.py 2021-04-23 16:43:40 +0000
1091+++ bin/addons/account/invoice.py 2021-11-03 13:33:55 +0000
1092@@ -28,7 +28,7 @@
1093 from tools.translate import _
1094 from msf_partner import PARTNER_TYPE
1095 from base import currency_date
1096-
1097+from tools.safe_eval import safe_eval
1098
1099 class account_invoice(osv.osv):
1100 def _amount_all(self, cr, uid, ids, name, args, context=None):
1101@@ -46,21 +46,6 @@
1102 res[invoice.id]['amount_total'] = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed']
1103 return res
1104
1105- def _get_journal(self, cr, uid, context=None):
1106- if context is None:
1107- context = {}
1108- type_inv = context.get('type', 'out_invoice')
1109- user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
1110- company_id = context.get('company_id', user.company_id.id)
1111- type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale_refund', 'in_refund': 'purchase_refund'}
1112- refund_journal = {'out_invoice': False, 'in_invoice': False, 'out_refund': True, 'in_refund': True}
1113- journal_obj = self.pool.get('account.journal')
1114- res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale')),
1115- ('company_id', '=', company_id),
1116- ('refund_journal', '=', refund_journal.get(type_inv, False))],
1117- limit=1)
1118- return res and res[0] or False
1119-
1120 def _get_journal_analytic(self, cr, uid, type_inv, context=None):
1121 type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'}
1122 tt = type2journal.get(type_inv, 'sale')
1123@@ -363,7 +348,6 @@
1124 _defaults = {
1125 'type': _get_type,
1126 'state': 'draft',
1127- 'journal_id': _get_journal,
1128 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
1129 'reference_type': 'none',
1130 'check_total': 0.0,
1131@@ -371,52 +355,76 @@
1132 'user_id': lambda s, cr, u, c: u,
1133 }
1134
1135+ def _set_invoice_name(self, cr, uid, doc, context=None):
1136+ """
1137+ Sets the correct invoice name to be displayed depending on the doc_type
1138+ """
1139+ if context is None:
1140+ context = {}
1141+ if context.get('doc_type'):
1142+ for doc_type in self._get_invoice_type_list(cr, uid, context=context):
1143+ if context['doc_type'] in doc_type:
1144+ doc.attrib['string'] = doc_type[1]
1145+ break
1146+ return True
1147+
1148 def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
1149- journal_obj = self.pool.get('account.journal')
1150 if context is None:
1151 context = {}
1152-
1153- if context.get('active_model', '') in ['res.partner'] and context.get('active_ids', False) and context['active_ids']:
1154- partner = self.pool.get(context['active_model']).read(cr, uid, context['active_ids'], ['supplier','customer'])[0]
1155- if not view_type:
1156- view_id = self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'account.invoice.tree')])
1157- view_type = 'tree'
1158- if view_type == 'form':
1159- if partner['supplier'] and not partner['customer']:
1160- view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.supplier.form')])
1161- else:
1162- view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.form')])
1163 if view_id and isinstance(view_id, (list, tuple)):
1164 view_id = view_id[0]
1165 res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
1166-
1167- type = context.get('journal_type', 'sale')
1168- if 'journal_id' in res['fields']:
1169- filter_journal = [('type', '=', type), ('is_current_instance','=',True)]
1170- if type == 'inkind' and context.get('is_inkind_donation'):
1171- filter_journal = [('is_current_instance','=',True), ('type', 'in', ('inkind', 'extra'))]
1172- journal_select = journal_obj._name_search(cr, uid, '', filter_journal, context=context, limit=None, name_get_uid=1)
1173- res['fields']['journal_id']['selection'] = journal_select
1174-
1175- if view_type == 'form' and context.get('type', 'out_invoice') == 'in_refund':
1176+ if view_type == 'form':
1177 doc = etree.XML(res['arch'])
1178- doc.attrib['string'] = _('Supplier Refund')
1179- nodes = doc.xpath("//field[@name='amount_to_pay']")
1180- for node in nodes:
1181- node.set('string', _('Amount to be refunded'))
1182+ if context.get('type', 'out_invoice') == 'in_refund' or context.get('doc_type', '') == 'isr':
1183+ nodes = doc.xpath("//field[@name='amount_to_pay']")
1184+ for node in nodes:
1185+ node.set('string', _('Amount to be refunded'))
1186+ # adapt the form name depending on the doc_type (used e.g. when clicking on a res.log)
1187+ self._set_invoice_name(cr, uid, doc, context=context)
1188+ """
1189+ Restriction on allowed partners:
1190+ - for STV/STR: Intersection or External customers only
1191+ - for ISI/ISR: Intersection suppliers only
1192+ - for SI/SR: non-Intersection suppliers only
1193+ """
1194+ partner_domain = ""
1195+ if context.get('doc_type', '') in ('stv', 'str') or (
1196+ context.get('type', False) == 'out_invoice' and context.get('journal_type', False) == 'sale' and
1197+ not context.get('is_debit_note', False) and not context.get('is_intermission', False)
1198+ ):
1199+ partner_domain = "[('partner_type', 'in', ('section', 'external')), ('customer', '=', True)]"
1200+ elif context.get('doc_type', '') in ('isi', 'isr'):
1201+ partner_domain = "[('partner_type', '=', 'section'), ('supplier', '=', True)]"
1202+ elif (context.get('doc_type', '') in ('si', 'sr')) or \
1203+ (context.get('type') == 'in_invoice' and context.get('journal_type') == 'purchase') or \
1204+ (context.get('type') == 'in_refund' and context.get('journal_type') == 'purchase_refund'):
1205+ partner_domain = "[('partner_type', '!=', 'section'), ('supplier', '=', True)]"
1206+ if partner_domain:
1207+ partner_nodes = doc.xpath("//field[@name='partner_id']")
1208+ for node in partner_nodes:
1209+ node.set('domain', partner_domain)
1210 res['arch'] = etree.tostring(doc)
1211-
1212- if view_type == 'tree':
1213+ elif view_type == 'tree':
1214 doc = etree.XML(res['arch'])
1215- nodes = doc.xpath("//field[@name='partner_id']")
1216 # (US-777) Remove the possibility to create new invoices through the "Advance Return" Wizard
1217 if context.get('from_wizard') and context.get('from_wizard')['model'] == 'wizard.cash.return':
1218 doc.set('hide_new_button', 'True')
1219- partner_string = _('Customer')
1220- if context.get('type', 'out_invoice') in ('in_invoice', 'in_refund'):
1221+ # adapt the name of the Partner field depending on the view
1222+ nodes = doc.xpath("//field[@name='partner_id']")
1223+ if context.get('generic_invoice') or context.get('journal_type') == 'intermission':
1224+ # for tree views combining Customer and Supplier Invoices, or for IVI/IVO
1225+ partner_string = _('Partner')
1226+ elif context.get('journal_type', False) == 'inkind':
1227+ partner_string = _('Donor')
1228+ elif context.get('type', 'out_invoice') in ('in_invoice', 'in_refund') or context.get('doc_type', '') in ('isi', 'isr'):
1229 partner_string = _('Supplier')
1230+ else:
1231+ partner_string = _('Customer')
1232 for node in nodes:
1233 node.set('string', partner_string)
1234+ # ensure that the doc name remains consistent even after clicking on a filter in the Search View
1235+ self._set_invoice_name(cr, uid, doc, context=context)
1236 res['arch'] = etree.tostring(doc)
1237 elif view_type == 'search':
1238 # remove the Cancel filter in all invoices but IVO and STV (in Donations the filter is named differently)
1239@@ -430,20 +438,14 @@
1240 if filter_node:
1241 filter_node[0].getparent().remove(filter_node[0])
1242 res['arch'] = etree.tostring(doc)
1243+ if view_type in ('tree', 'search') and (context.get('type') in ['out_invoice', 'out_refund'] or context.get('doc_type') == 'str'):
1244+ doc = etree.XML(res['arch'])
1245+ nodes = doc.xpath("//field[@name='supplier_reference']")
1246+ for node in nodes:
1247+ node.getparent().remove(node)
1248+ res['arch'] = etree.tostring(doc)
1249 return res
1250
1251- def get_log_context(self, cr, uid, context=None):
1252- if context is None:
1253- context = {}
1254- is_intermission = context.get('is_intermission', False)
1255- if is_intermission:
1256- res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_override', 'view_intermission_form')
1257- else:
1258- res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'invoice_form')
1259- view_id = res and res[1] or False
1260- context.update({'view_id': view_id})
1261- return context
1262-
1263 def create(self, cr, uid, vals, context=None):
1264 if context is None:
1265 context = {}
1266@@ -453,8 +455,6 @@
1267 ctx = context.copy()
1268 if 'is_intermission' in vals:
1269 ctx.update({'is_intermission': vals['is_intermission']})
1270- if vals.get('type', 'in_invoice') in ('out_invoice', 'out_refund'):
1271- ctx = self.get_log_context(cr, uid, context=ctx)
1272 if 'type' in vals:
1273 ctx.update({'type': vals['type']})
1274 if '_terp_view_name' in ctx:
1275@@ -633,10 +633,8 @@
1276 def onchange_partner_bank(self, cursor, user, ids, partner_bank_id=False):
1277 return {'value': {}}
1278
1279- def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id):
1280+ def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id, context=None):
1281 val = {}
1282- dom = {}
1283- obj_journal = self.pool.get('account.journal')
1284 account_obj = self.pool.get('account.account')
1285 inv_line_obj = self.pool.get('account.invoice.line')
1286 if company_id and part_id and type:
1287@@ -683,35 +681,13 @@
1288 _('Invoice line account company does not match with invoice company.'))
1289 else:
1290 continue
1291- if company_id and type:
1292- if type in ('out_invoice'):
1293- journal_type = 'sale'
1294- elif type in ('out_refund'):
1295- journal_type = 'sale_refund'
1296- elif type in ('in_refund'):
1297- journal_type = 'purchase_refund'
1298- else:
1299- journal_type = 'purchase'
1300- journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)])
1301- if journal_ids:
1302- val['journal_id'] = journal_ids[0]
1303- res_journal_default = self.pool.get('ir.values').get(cr, uid, 'default', 'type=%s' % (type), ['account.invoice'])
1304- for r in res_journal_default:
1305- if r[1] == 'journal_id' and r[2] in journal_ids:
1306- val['journal_id'] = r[2]
1307- if not val.get('journal_id', False):
1308- raise osv.except_osv(_('Configuration Error !'), (_('Can\'t find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Financial Accounting\Accounts\Journals.') % (journal_type)))
1309- dom = {'journal_id': [('id', 'in', journal_ids)]}
1310- else:
1311- journal_ids = obj_journal.search(cr, uid, [])
1312-
1313 if currency_id and company_id:
1314 currency = self.pool.get('res.currency').browse(cr, uid, currency_id)
1315 if currency.company_id and currency.company_id.id != company_id:
1316 val['currency_id'] = False
1317 else:
1318 val['currency_id'] = currency.id
1319- return {'value': val, 'domain': dom}
1320+ return {'value': val}
1321
1322 def onchange_synced(self, cr, uid, ids, synced, partner_id):
1323 """
1324@@ -899,11 +875,12 @@
1325 i['currency_id'] = inv.currency_id.id
1326 i['amount_currency'] = i['price']
1327 i['ref'] = ref
1328- if inv.type in ('out_invoice','in_refund'):
1329+ # the direction of the amounts depends on the invoice type
1330+ if inv.doc_type in ('stv', 'ivo', 'dn', 'sr', 'isr'):
1331 i['price'] = -i['price']
1332 i['amount_currency'] = - i['amount_currency']
1333 i['change_sign'] = True
1334- else:
1335+ else: # 'str', 'ivi', 'si', 'di', 'isi', 'cr', 'donation'
1336 i['change_sign'] = False
1337 total -= i['amount_currency']
1338 return total, invoice_move_lines
1339@@ -1008,6 +985,7 @@
1340 # UTP-594: Get ref and name
1341 if inv.type == 'in_invoice':
1342 is_ivi = inv.is_intermission and not inv.is_debit_note and not inv.is_inkind_donation
1343+ # SI or ISI
1344 is_si = not inv.is_direct_invoice and not inv.is_inkind_donation and not inv.is_debit_note and not inv.is_intermission
1345 intersection = inv.partner_id.partner_type == 'section'
1346 external = inv.partner_id.partner_type == 'external'
1347@@ -1232,8 +1210,6 @@
1348
1349 for inv_id, name in self.name_get(cr, uid, [id]):
1350 ctx = context.copy()
1351- if obj_inv.type in ('out_invoice', 'out_refund'):
1352- ctx = self.get_log_context(cr, uid, context=ctx)
1353 ctx['type'] = obj_inv.type
1354 message = _('Invoice ') + " '" + name + "' "+ _("is validated.")
1355 self.log(cr, uid, inv_id, message, context=ctx)
1356@@ -1243,6 +1219,13 @@
1357 """
1358 Sets the invoice to Cancelled and not Synchronized
1359 """
1360+ if isinstance(ids, (int, long)):
1361+ ids = [ids]
1362+
1363+ draft_invoice_ids = self.search(cr, uid, [('state', '=', 'draft'), ('id', 'in', ids)])
1364+ if draft_invoice_ids:
1365+ self.update_commitments(cr, uid, draft_invoice_ids)
1366+
1367 self.write(cr, uid, ids, {'state': 'cancel', 'synced': False})
1368 return True
1369
1370@@ -1291,13 +1274,22 @@
1371 def name_get(self, cr, uid, ids, context=None):
1372 if not ids:
1373 return []
1374- types = {
1375- 'out_invoice': 'CI: ',
1376- 'in_invoice': 'SI: ',
1377- 'out_refund': 'OR: ',
1378- 'in_refund': 'SR: ',
1379+ doc_types = {
1380+ 'stv': _('STV: '),
1381+ 'str': _('STR: '),
1382+ 'cr': _('CR: '),
1383+ 'dn': _('DN: '),
1384+ 'ivo': _('IVO: '),
1385+ 'si': _('SI: '),
1386+ 'di': _('DI: '),
1387+ 'sr': _('SR: '),
1388+ 'isi': _('ISI: '),
1389+ 'isr': _('ISR: '),
1390+ 'donation': _('DON: '),
1391+ 'ivi': _('IVI: '),
1392 }
1393- return [(r['id'], (r['number']) or types[r['type']] + (r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')]
1394+ return [(r['id'], (r['number']) or doc_types[r['doc_type']] + (r['name'] or '')) for r in
1395+ self.read(cr, uid, ids, ['doc_type', 'number', 'name'], context, load='_classic_write')]
1396
1397 def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
1398 if not args:
1399@@ -1364,8 +1356,8 @@
1400 """
1401 res = [
1402 'name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'address_contact_id', 'address_invoice_id',
1403- 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id',
1404- 'analytic_distribution_id', 'document_date',
1405+ 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line',
1406+ 'journal_id', 'analytic_distribution_id', 'document_date', 'doc_type',
1407 ]
1408 return res
1409
1410@@ -1441,10 +1433,24 @@
1411 else:
1412 refund_journal_ids = obj_journal.search(cr, uid, [('type','=','sale_refund')])
1413
1414+ if invoice.get('doc_type') == 'stv':
1415+ doc_type = 'str'
1416+ elif invoice.get('doc_type') == 'isi':
1417+ doc_type = 'isr'
1418+ elif invoice.get('doc_type') in ('si', 'di'):
1419+ doc_type = 'sr'
1420+ elif invoice.get('doc_type') == 'ivo':
1421+ doc_type = 'ivi'
1422+ elif invoice.get('doc_type') == 'ivi':
1423+ doc_type = 'ivo'
1424+ else:
1425+ doc_type = ''
1426+
1427 if not date:
1428 date = time.strftime('%Y-%m-%d')
1429 invoice.update({
1430 'type': type_dict[invoice['type']],
1431+ 'real_doc_type': doc_type,
1432 'date_invoice': date,
1433 'state': 'draft',
1434 'number': False,
1435@@ -1474,7 +1480,7 @@
1436 invoice[field] = invoice[field] and invoice[field][0]
1437 invoice = self._hook_refund_data(cr, uid, invoice) or invoice
1438 # create the new invoice
1439- new_ids.append(self.create(cr, uid, invoice))
1440+ new_ids.append(self.create(cr, uid, invoice, context=context))
1441
1442 return new_ids
1443
1444@@ -1584,6 +1590,21 @@
1445 'account.invoice.update_counterpart_inv', self._logger, check_identifier=False, context=context)
1446 return True
1447
1448+ def invoice_open_form_view(self, cr, uid, ids, context=None):
1449+ if not ids:
1450+ return True
1451+ view_data = self._get_invoice_act_window(cr, uid, ids[0], views_order=['form', 'tree'], context=context)
1452+ view_data['res_id'] = ids[0]
1453+ view_data['target'] = 'current'
1454+ view_data['keep_open'] = True
1455+ if context.get('search_default_partner_id'):
1456+ dom = []
1457+ if view_data['domain']:
1458+ dom = safe_eval(view_data['domain'])
1459+ dom.append(('partner_id', '=', context.get('search_default_partner_id')))
1460+ view_data['domain'] = dom
1461+ return view_data
1462+
1463 account_invoice()
1464
1465 class account_invoice_line(osv.osv):
1466@@ -2140,7 +2161,7 @@
1467 def get(self, cr, uid, key, key2, models, meta=False, context=None, res_id_req=False, without_user=True, key2_req=True, view_id=False):
1468 """
1469 Hides the reports:
1470- - "Invoice Excel Export" in the menu of other invoices than IVO/IVI
1471+ - "Invoice Excel Export" in the menu of other invoices than IVO/IVI/STV
1472 - "FO Follow-up Finance" in the menu of other invoices than IVO/STV
1473 - "STV/IVO lines follow-up" in the menu of other invoices than IVO/STV (+ renames it depending on the inv. type)
1474 """
1475@@ -2162,7 +2183,8 @@
1476 elif context_stv:
1477 v[2]['name'] = _('STV lines follow-up')
1478 # display
1479- if not context.get('is_intermission') and len(v) > 2 and v[2].get('report_name', '') == 'invoice.excel.export':
1480+ if not context.get('is_intermission') and not context_stv and len(v) > 2 and \
1481+ v[2].get('report_name', '') == 'invoice.excel.export':
1482 continue
1483 elif not context_ivo and not context_stv and len(v) > 1 and v[1] in ('fo_follow_up_finance', 'invoice_lines_follow_up'):
1484 continue
1485
1486=== modified file 'bin/addons/account/report/account_print_invoice.rml'
1487--- bin/addons/account/report/account_print_invoice.rml 2019-03-22 14:16:36 +0000
1488+++ bin/addons/account/report/account_print_invoice.rml 2021-11-03 13:33:55 +0000
1489@@ -139,6 +139,7 @@
1490 </stylesheet>
1491 <story>
1492 <pto>
1493+ <!-- NOTE: this report seems to be overwritten by account_override/report/account_print_invoice.rml -->
1494 <para style="terp_default_8">[[ repeatIn(objects,'o') ]]</para>
1495 <para style="terp_default_8"></para>
1496 <pto_header><!-- Must be after setLang() -->
1497
1498=== modified file 'bin/addons/account/report/export_invoice.py'
1499--- bin/addons/account/report/export_invoice.py 2021-04-27 16:09:42 +0000
1500+++ bin/addons/account/report/export_invoice.py 2021-11-03 13:33:55 +0000
1501@@ -27,13 +27,13 @@
1502 """
1503 Returns True if the fields Product and Quantity of the invoice must be readonly = not editable
1504 """
1505- if inv.type == 'in_invoice' and not inv.is_direct_invoice and not inv.is_inkind_donation: # IVI or SI
1506+ if inv.doc_type in ('ivi', 'si', 'isi'):
1507 is_readonly = inv.from_supply or inv.synced
1508- elif inv.type == 'out_invoice' and inv.is_intermission: # IVO
1509+ elif inv.doc_type == 'ivo':
1510 is_readonly = inv.from_supply
1511- elif inv.type == 'out_invoice' and not inv.is_intermission and not inv.is_debit_note: # STV
1512+ elif inv.doc_type == 'stv':
1513 is_readonly = inv.from_supply and inv.partner_type == 'section'
1514- elif inv.type == 'in_invoice' and inv.is_inkind_donation: # Donation
1515+ elif inv.doc_type == 'donation':
1516 is_readonly = inv.from_supply
1517 else: # other inv. types are not supposed to be handled in this report
1518 is_readonly = True
1519
1520=== modified file 'bin/addons/account/report/invoice_excel_export.py'
1521--- bin/addons/account/report/invoice_excel_export.py 2020-04-09 09:06:08 +0000
1522+++ bin/addons/account/report/invoice_excel_export.py 2021-11-03 13:33:55 +0000
1523@@ -37,8 +37,10 @@
1524
1525 def _get_distribution_lines(self, inv_line):
1526 """
1527- Returns distrib. line data related to the invoice line in parameter, as a list of dicts
1528- Note: it gives a result even for lines without AD: the line subtotal is retrieved in any cases
1529+ Returns distrib. line data related to the invoice line in parameter, as a list of dicts.
1530+ Notes:
1531+ - it gives a result even for lines without AD: the line subtotal is retrieved in any cases
1532+ - only CC and Dest are retrieved, FP is excluded.
1533 """
1534 fp_distrib_line_obj = self.pool.get('funding.pool.distribution.line')
1535 distrib_lines = []
1536@@ -69,18 +71,19 @@
1537
1538 def _get_shipment_number(self, inv):
1539 """
1540- Returns the "shipment" or "simple OUT" number having generated the IVO if linked to a supply workflow
1541- Displayed for both the IVO and the IVI.
1542+ Returns the "shipment" or "simple OUT" number having generated the IVO/STV if linked to a supply workflow
1543+ Displayed for both the IVO/STV and the IVI.
1544 """
1545 if self.invoices.get(inv.id, {}).get('shipment', None) is not None:
1546 # process only once per invoice
1547 return self.invoices[inv.id]['shipment']
1548 ship_or_out_ref = ''
1549- if inv.from_supply and inv.is_intermission:
1550- if inv.type == 'out_invoice': # IVO
1551+ if inv.from_supply:
1552+ inv_type = self.pool.get('account.invoice').read(self.cr, self.uid, inv.id, ['doc_type'])['doc_type']
1553+ if inv_type in ('ivo', 'stv'):
1554 if inv.name:
1555 ship_or_out_ref = inv.name.split()[-1]
1556- elif inv.type == 'in_invoice': # IVI
1557+ elif inv_type == 'ivi':
1558 if inv.picking_id:
1559 ship_or_out_ref = inv.picking_id.shipment_ref or ''
1560 self.invoices.setdefault(inv.id, {}).update({'shipment': ship_or_out_ref})
1561@@ -88,20 +91,21 @@
1562
1563 def _get_fo_number(self, inv):
1564 """
1565- Returns the FO number related to the IVO if any.
1566- Displayed for both the IVO and the IVI.
1567+ Returns the FO number related to the IVO/STV if any.
1568+ Displayed for both the IVO/STV and the IVI.
1569 """
1570 if self.invoices.get(inv.id, {}).get('fo', None) is not None:
1571 # process only once per invoice
1572 return self.invoices[inv.id]['fo']
1573 fo_number = ''
1574- if inv.from_supply and inv.is_intermission:
1575- if inv.type == 'out_invoice': # IVO
1576+ if inv.from_supply:
1577+ inv_type = self.pool.get('account.invoice').read(self.cr, self.uid, inv.id, ['doc_type'])['doc_type']
1578+ if inv_type in ('ivo', 'stv'):
1579 if inv.origin:
1580 inv_source_doc_split = inv.origin.split(':')
1581 if inv_source_doc_split:
1582 fo_number = inv_source_doc_split[-1]
1583- elif inv.type == 'in_invoice': # IVI
1584+ elif inv_type == 'ivi':
1585 if inv.main_purchase_id:
1586 fo_number = inv.main_purchase_id.short_partner_ref or ''
1587 self.invoices.setdefault(inv.id, {}).update({'fo': fo_number})
1588@@ -109,25 +113,26 @@
1589
1590 def _get_po_number(self, inv_line):
1591 """
1592- Returns the PO number for Intermission Voucher Lines linked to a supply workflow.
1593- For the IVO: PO to the external partner in order to buy the goods
1594+ Returns the PO number for the lines linked to a supply workflow.
1595+ For the IVO/STV: PO to the external partner in order to buy the goods
1596 For the IVI: PO to the intermission partner which triggered the creation of the FO
1597 """
1598 inv = inv_line.invoice_id
1599- ivo_from_supply = inv.is_intermission and inv.type == 'out_invoice' and inv.from_supply
1600- if not ivo_from_supply and self.invoices.get(inv.id, {}).get('po', None) is not None:
1601- # process only once per invoice except for IVO from Supply where the check must be done line by line
1602+ inv_type = self.pool.get('account.invoice').read(self.cr, self.uid, inv.id, ['doc_type'])['doc_type']
1603+ out_inv_from_supply = inv_type in ('ivo', 'stv') and inv.from_supply
1604+ if not out_inv_from_supply and self.invoices.get(inv.id, {}).get('po', None) is not None:
1605+ # process only once per invoice except for IVO/STV from Supply where the check must be done line by line
1606 return self.invoices[inv.id]['po']
1607 po_number = ''
1608 po_line_obj = self.pool.get('purchase.order.line')
1609- if inv.from_supply and inv.is_intermission:
1610- if inv.type == 'out_invoice': # IVO
1611+ if inv.from_supply:
1612+ if inv_type in ('ivo', 'stv'):
1613 fo_line = inv_line.sale_order_line_id
1614 if fo_line and fo_line.type == 'make_to_order': # the line is sourced on a PO
1615 pol_ids = po_line_obj.search(self.cr, self.uid, [('sale_order_line_id', '=', fo_line.id)])
1616 if pol_ids:
1617 po_number = po_line_obj.browse(self.cr, self.uid, pol_ids[0], fields_to_fetch=['order_id']).order_id.name
1618- elif inv.type == 'in_invoice': # IVI
1619+ elif inv_type == 'ivi':
1620 if inv.main_purchase_id:
1621 po_number = inv.main_purchase_id.name
1622 self.invoices.setdefault(inv.id, {}).update({'po': po_number})
1623
1624=== modified file 'bin/addons/account/wizard/account_invoice_import.py'
1625--- bin/addons/account/wizard/account_invoice_import.py 2021-04-28 15:14:26 +0000
1626+++ bin/addons/account/wizard/account_invoice_import.py 2021-11-03 13:33:55 +0000
1627@@ -200,7 +200,7 @@
1628 elif invoice.is_inkind_donation: # for Donations
1629 restricted_area = 'donation_lines'
1630 else:
1631- restricted_area = 'invoice_lines' # for SI / STV
1632+ restricted_area = 'invoice_lines' # for SI / STV / ISI
1633 if not account_obj.search_exist(cr, uid, [('id', '=', account.id), ('restricted_area', '=', restricted_area)],
1634 context=context):
1635 errors.append(_("Line %s: the account %s is not allowed.") % (current_line_num, account_code))
1636
1637=== modified file 'bin/addons/account/wizard/account_invoice_refund.py'
1638--- bin/addons/account/wizard/account_invoice_refund.py 2020-02-10 13:07:40 +0000
1639+++ bin/addons/account/wizard/account_invoice_refund.py 2021-11-03 13:33:55 +0000
1640@@ -32,13 +32,17 @@
1641
1642 def _get_filter_refund(self, cr, uid, context=None):
1643 """
1644- Returns the selectable Refund Types (no simple "Refund" in case of an IVO/IVI)
1645+ Returns the selectable Refund Types (no simple "Refund" in case of an IVO/IVI or STV, only Refund/Cancel in case of an ISI)
1646 """
1647 if context is None:
1648 context = {}
1649- if context.get('is_intermission', False):
1650- return [('modify', 'Modify'), ('cancel', 'Cancel')]
1651- return [('modify', 'Modify'), ('refund', 'Refund'), ('cancel', 'Cancel')]
1652+ refund_types = [('modify', 'Modify'), ('refund', 'Refund'), ('cancel', 'Cancel')]
1653+ if context.get('is_intermission', False) or context.get('doc_type', '') == 'stv':
1654+ refund_types = [('modify', 'Modify'), ('cancel', 'Cancel')]
1655+ elif context.get('doc_type', '') == 'isi':
1656+ # note: Refund Cancel is allowed only if the counterpart invoice is closed (handled directly in ISI form)
1657+ refund_types = [('cancel', 'Cancel')]
1658+ return refund_types
1659
1660 _columns = {
1661 'date': fields.date('Operation date', help='This date will be used as the invoice date for Refund Invoice and Period will be chosen accordingly!'),
1662@@ -49,35 +53,10 @@
1663 'filter_refund': fields.selection(_get_filter_refund, "Refund Type", required=True, help='Refund invoice based on this type. You can not Modify and Cancel if the invoice is already reconciled'),
1664 }
1665
1666- def _get_journal(self, cr, uid, context=None):
1667- obj_journal = self.pool.get('account.journal')
1668- if context is None:
1669- context = {}
1670- journal = obj_journal.search(cr, uid, [('type', '=', 'sale_refund')])
1671- if context.get('type', False):
1672- if context['type'] in ('in_invoice', 'in_refund'):
1673- journal = obj_journal.search(cr, uid, [('type', '=', 'purchase_refund')])
1674- return journal and journal[0] or False
1675-
1676 _defaults = {
1677- 'journal_id': _get_journal,
1678 'filter_refund': 'modify',
1679 }
1680
1681- def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
1682- journal_obj = self.pool.get('account.journal')
1683- res = super(account_invoice_refund,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
1684- type = context.get('journal_type', 'sale_refund')
1685- if type in ('sale', 'sale_refund'):
1686- type = 'sale_refund'
1687- else:
1688- type = 'purchase_refund'
1689- for field in res['fields']:
1690- if field == 'journal_id':
1691- journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1)
1692- res['fields'][field]['selection'] = journal_select
1693- return res
1694-
1695 def _hook_fields_for_modify_refund(self, cr, uid, *args):
1696 """
1697 Permits to change values that are taken from initial invoice to new invoice(s)
1698@@ -94,11 +73,24 @@
1699 res = ['address_contact_id', 'address_invoice_id', 'partner_id', 'account_id', 'currency_id', 'payment_term', 'journal_id']
1700 return res
1701
1702- def _hook_create_invoice(self, cr, uid, data, form, *args):
1703+ def _get_invoice_context(self, context):
1704+ """
1705+ Gets the context to be used in _hook_create_invoice
1706+
1707+ US-8585: for now only "from_refund_button" is handled, the context is otherwise empty in order not to break the current behavior.
1708+ """
1709+ if context and context.get('from_refund_button'):
1710+ inv_context = {'from_refund_button': True}
1711+ else:
1712+ inv_context = {}
1713+ return inv_context
1714+
1715+ def _hook_create_invoice(self, cr, uid, data, form, context=None):
1716 """
1717 Permits to adapt invoice creation
1718 """
1719- res = self.pool.get('account.invoice').create(cr, uid, data, {})
1720+ inv_context = self._get_invoice_context(context)
1721+ res = self.pool.get('account.invoice').create(cr, uid, data, context=inv_context)
1722 return res
1723
1724 def _hook_create_refund(self, cr, uid, inv_ids, date, period, description, journal_id, form, context=None):
1725@@ -134,7 +126,6 @@
1726 inv_obj = self.pool.get('account.invoice')
1727 reconcile_obj = self.pool.get('account.move.reconcile')
1728 account_m_line_obj = self.pool.get('account.move.line')
1729- mod_obj = self.pool.get('ir.model.data')
1730 act_obj = self.pool.get('ir.actions.act_window')
1731 wf_service = netsvc.LocalService('workflow')
1732 inv_tax_obj = self.pool.get('account.invoice.tax')
1733@@ -158,14 +149,13 @@
1734 if mode in ('cancel', 'modify') and not inv.account_id.reconcile:
1735 raise osv.except_osv(_('Error !'), _("Cannot Cancel / Modify if the account can't be reconciled."))
1736 if mode in ('cancel', 'modify') and inv_obj.has_one_line_reconciled(cr, uid, [inv.id], context=context):
1737- if inv.is_intermission:
1738- # error specific to IVO/IVI for which there is no simple refund option
1739- raise osv.except_osv(_('Error !'), _('Cannot %s an Intermission Voucher which is already reconciled, it should be unreconciled first.') % _(mode))
1740- if inv.state == 'inv_close':
1741- raise osv.except_osv(_('Error !'), _('Can not %s invoice which is already reconciled, invoice should be unreconciled first.') % (mode))
1742+ if inv.state == 'inv_close' or inv.is_intermission or inv.doc_type in ('stv', 'isi'):
1743+ # error msg specific to UC where there is no simple refund option
1744+ raise osv.except_osv(_('Error !'), _('Cannot %s an invoice which is already reconciled, '
1745+ 'it should be unreconciled first.') % _(mode))
1746 else:
1747- raise osv.except_osv(_('Error !'), _('Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice') % (mode))
1748-
1749+ raise osv.except_osv(_('Error !'), _('Cannot %s an invoice which is already reconciled, '
1750+ 'it should be unreconciled first. You can only Refund this invoice.') % _(mode))
1751 if mode == 'refund' and inv.state == 'inv_close':
1752 raise osv.except_osv(_('Error !'), _('It is not possible to refund a Closed invoice'))
1753
1754@@ -252,6 +242,7 @@
1755 source_doc = invoice.get('number', False)
1756 invoice.update({
1757 'type': inv.type,
1758+ 'real_doc_type': inv.doc_type or '',
1759 'date_invoice': date,
1760 'state': 'draft',
1761 'number': False,
1762@@ -264,7 +255,7 @@
1763 })
1764 for field in self._hook_fields_m2o_for_modify_refund(cr, uid):
1765 invoice[field] = invoice[field] and invoice[field][0]
1766- inv_id = self._hook_create_invoice(cr, uid, invoice, form)
1767+ inv_id = self._hook_create_invoice(cr, uid, invoice, form, context=context)
1768 if inv.payment_term.id:
1769 data = inv_obj.onchange_payment_term_date_invoice(cr, uid, [inv_id], inv.payment_term.id, date)
1770 if 'value' in data and data['value']:
1771@@ -283,28 +274,29 @@
1772 ji_ids.extend([sr_ji.id for sr_ji in refund.move_id.line_id])
1773 # write on JIs without recreating AJIs
1774 account_m_line_obj.write(cr, uid, ji_ids, {'is_si_refund': True}, context=context, check=False, update_check=False)
1775-
1776- if context.get('is_intermission', False):
1777- module = 'account_override'
1778- if inv.type == 'in_invoice':
1779- xml_id = 'action_intermission_out'
1780- else:
1781- xml_id = 'action_intermission_in'
1782- else:
1783- module = 'account'
1784- if inv.type in ('out_invoice', 'out_refund'):
1785- xml_id = 'action_invoice_tree3'
1786- else:
1787- xml_id = 'action_invoice_tree4'
1788- result = mod_obj.get_object_reference(cr, uid, module, xml_id)
1789- id = result and result[1] or False
1790- result = act_obj.read(cr, uid, id, context=context)
1791+ # return to a tree view containing the refund generated
1792+ from_doc_type = context.get('doc_type', '')
1793+ if from_doc_type == 'stv':
1794+ return_doc_type = 'str'
1795+ elif from_doc_type == 'ivo':
1796+ return_doc_type = 'ivi'
1797+ elif from_doc_type == 'ivi':
1798+ return_doc_type = 'ivo'
1799+ elif from_doc_type == 'isi':
1800+ return_doc_type = 'isr'
1801+ else: # i.e. si, di
1802+ return_doc_type = 'sr'
1803+ action_act_window = inv_obj._invoice_action_act_window[return_doc_type]
1804+ result = act_obj.open_view_from_xmlid(cr, uid, action_act_window, context=context)
1805 invoice_domain = eval(result['domain'])
1806 invoice_domain.append(('id', 'in', created_inv))
1807 result['domain'] = invoice_domain
1808 return result
1809
1810 def invoice_refund(self, cr, uid, ids, context=None):
1811+ if context is None:
1812+ context = {}
1813+ context.update({'from_refund_button': True})
1814 data_refund = self.read(cr, uid, ids[0], ['filter_refund'], context=context)['filter_refund']
1815 return self.compute_refund(cr, uid, ids, data_refund, context=context)
1816
1817
1818=== modified file 'bin/addons/account/wizard/account_invoice_refund_view.xml'
1819--- bin/addons/account/wizard/account_invoice_refund_view.xml 2019-06-24 14:40:19 +0000
1820+++ bin/addons/account/wizard/account_invoice_refund_view.xml 2021-11-03 13:33:55 +0000
1821@@ -14,13 +14,17 @@
1822 <field name="journal_id" required="1"/>
1823 <field name="date" required="1"/>
1824 <field name="period"/>
1825- <field name="filter_refund"/>
1826+ <field name="filter_refund" attrs="{'readonly': [('is_isi', '=', True)]}"/>
1827 <field name="is_intermission" invisible="1"/>
1828+ <field name="is_stv" invisible="1"/>
1829+ <field name="is_isi" invisible="1"/>
1830 </group>
1831 <separator colspan="4"/>
1832 <group col="4" colspan="4" fill="1">
1833- <label align="0.0" width="550" colspan="4" string="Modify Invoice: Cancels the current invoice and creates a new copy of it ready for editing."/>
1834- <group attrs="{'invisible': [('is_intermission', '=', True)] }">
1835+ <group attrs="{'invisible': [('is_isi', '=', True)]}">
1836+ <label align="0.0" width="550" colspan="4" string="Modify Invoice: Cancels the current invoice and creates a new copy of it ready for editing."/>
1837+ </group>
1838+ <group attrs="{'invisible': ['|', '|', ('is_intermission', '=', True), ('is_stv', '=', True), ('is_isi', '=', True)]}">
1839 <label align="0.0" width="300" string="Refund Invoice: Creates the refund invoice, ready for editing."/>
1840 </group>
1841 <label align="0.0" width="500" colspan="4" string="Cancel Invoice: Creates the refund invoice, validate and reconcile it to cancel the current invoice."/>
1842
1843=== modified file 'bin/addons/account_hq_entries/account_view.xml'
1844--- bin/addons/account_hq_entries/account_view.xml 2019-01-10 13:48:23 +0000
1845+++ bin/addons/account_hq_entries/account_view.xml 2021-11-03 13:33:55 +0000
1846@@ -192,40 +192,6 @@
1847 </field>
1848 </record>
1849
1850- <!--
1851- New account attribute for HQ entries corrections
1852- -->
1853-
1854- <record id="inherit_view_account_form2" model="ir.ui.view">
1855- <field name='name'>inherit.view.account.form2</field>
1856- <field name='model'>account.account</field>
1857- <field name="type">form</field>
1858- <field name='inherit_id' ref='account.view_account_form'/>
1859- <field name="priority">30</field>
1860- <field name="arch" type="xml">
1861- <xpath expr="//field[@name='user_type']" position="after">
1862- <field name="is_not_hq_correctible" on_change="onchange_is_not_hq_correctible(is_not_hq_correctible)"/>
1863- <newline/>
1864- <label string="" colspan="2"/>
1865- <field name="is_not_ad_correctable" on_change="onchange_is_not_ad_correctable(is_not_ad_correctable)"/>
1866- </xpath>
1867- </field>
1868- </record>
1869-
1870- <record id="inherit_view_account_tree2" model="ir.ui.view">
1871- <field name='name'>inherit.view.account.tree2</field>
1872- <field name='model'>account.account</field>
1873- <field name="type">tree</field>
1874- <field name='inherit_id' ref='account.view_account_tree'/>
1875- <field name="priority" eval="20"/>
1876- <field name="arch" type="xml">
1877- <xpath expr="//field[@name='activation_date']" position="before">
1878- <field name="is_not_hq_correctible" invisible="1"/>
1879- </xpath>
1880- </field>
1881- </record>
1882-
1883-
1884 <!-- Actions: Menu actions -->
1885 <record id="action_hq_entries_import_wizard" model="ir.actions.act_window">
1886 <field name="name">Import HQ Entries</field>
1887
1888=== modified file 'bin/addons/account_mcdb/account_view.xml'
1889--- bin/addons/account_mcdb/account_view.xml 2020-08-06 16:10:07 +0000
1890+++ bin/addons/account_mcdb/account_view.xml 2021-11-03 13:33:55 +0000
1891@@ -87,30 +87,6 @@
1892 </field>
1893 </record>
1894
1895- <!-- Account analytic line tree view -->
1896- <record model="ir.ui.view" id="account_analytic_line_default">
1897- <field name="name">account.analytic.line.default</field>
1898- <field name="model">account.analytic.line</field>
1899- <field name="type">tree</field>
1900- <field name="inherit_id" ref="account.view_account_analytic_line_tree"/>
1901- <field name="priority" eval="40"/>
1902- <field name="arch" type="xml">
1903- <data>
1904- <xpath expr="/tree/field[@name='journal_id']" position="before">
1905- <field name="is_reversal" invisible="1"/>
1906- <field name="journal_type" invisible="1"/>
1907- <field name="is_corrigible" invisible="1"/>
1908- <button name="button_corrections" type="object" string="Accounting info/correction"
1909- attrs="{'invisible': [('is_corrigible', '=', False)]}" icon="terp-mail-message-new"/>
1910- <field name="is_reallocated" invisible="1"/>
1911- <field name="last_corrected_id" invisible="1"/>
1912- <field name="is_engi" invisible="1"/>
1913- <button string="Have been reallocated" attrs="{'invisible': [('is_reallocated', '=', False), ('last_corrected_id', '=', False)]}" icon="terp-mail-" colspan="2" name="button_open_analytic_corrections" type="object"/>
1914- </xpath>
1915- </data>
1916- </field>
1917- </record>
1918-
1919 <!-- Actions -->
1920 <act_window id="analytic_distribution.action_mass_reallocation"
1921 name="Mass reallocation"
1922
1923=== modified file 'bin/addons/account_override/__init__.py'
1924--- bin/addons/account_override/__init__.py 2019-06-13 16:16:46 +0000
1925+++ bin/addons/account_override/__init__.py 2021-11-03 13:33:55 +0000
1926@@ -51,6 +51,8 @@
1927 #+ Supplier Invoice
1928 #+ Direct Invoice
1929 #+ Supplier refund
1930+ #+ Intersection Supplier Invoice
1931+ #+ Intersection Supplier Refund
1932 'in_invoice': [
1933 ('type', '!=', 'view'),
1934 # Either Payable/Payables or Payable/Tax or Regular/Debt or Regular/Cash or Regular/Income accounts
1935@@ -61,6 +63,7 @@
1936 ],
1937 # HEADER OF:
1938 #+ Stock Transfer Voucher
1939+ #+ Stock Transfer Refund
1940 #+ Customer Refund
1941 #+ Debit Notes
1942 'out_invoice': [
1943@@ -81,7 +84,10 @@
1944 #+ Supplier invoice
1945 #+ Direct invoice
1946 #+ Supplier refund
1947+ #+ Intersection supplier invoice
1948+ #+ Intersection supplier refund
1949 #+ Stock transfer voucher
1950+ #+ Stock transfer refund
1951 #+ Customer refund
1952 #+ Debit notes
1953 'invoice_lines': [
1954
1955=== modified file 'bin/addons/account_override/account.py'
1956--- bin/addons/account_override/account.py 2021-04-23 12:31:26 +0000
1957+++ bin/addons/account_override/account.py 2021-11-03 13:33:55 +0000
1958@@ -974,6 +974,7 @@
1959 required=True, states={'posted':[('readonly',True)]},
1960 domain="[('type', 'not in', "
1961 " ['accrual', 'hq', 'inkind', 'cur_adj', 'system', 'extra', 'correction', 'correction_hq']),"
1962+ "('code', '!=', 'ISI'), "
1963 "('instance_filter', '=', True)]",
1964 hide_default_menu=True),
1965 'document_date': fields.date('Document Date', size=255, required=True, help="Used for manual journal entries"),
1966
1967=== modified file 'bin/addons/account_override/account_invoice_sync.py'
1968--- bin/addons/account_override/account_invoice_sync.py 2021-08-05 15:24:04 +0000
1969+++ bin/addons/account_override/account_invoice_sync.py 2021-11-03 13:33:55 +0000
1970@@ -174,7 +174,7 @@
1971 """
1972 Creates automatic counterpart invoice at synchro time.
1973 Intermission workflow: an IVO sent generates an IVI
1974- Intersection workflow: an STV sent generates an SI
1975+ Intersection workflow: an STV sent generates an ISI
1976 """
1977 self._logger.info("+++ Create an account.invoice in %s matching the one sent by %s" % (cr.dbname, source))
1978 if context is None:
1979@@ -213,21 +213,24 @@
1980 inv_lines = invoice_dict.get('invoice_line', [])
1981 po = False
1982 vals = {}
1983- # STV in sending instance: generates an SI in the receiving instance
1984+ # STV in sending instance: generates an ISI in the receiving instance
1985 if journal_type == 'sale':
1986- pur_journal_ids = journal_obj.search(cr, uid, [('type', '=', 'purchase'), ('is_current_instance', '=', True)], limit=1, context=context)
1987- if not pur_journal_ids:
1988- raise osv.except_osv(_('Error'), _("No Purchase journal found for the current instance."))
1989- # for the SI use the Account Payable of the partner
1990- si_account = partner.property_account_payable
1991- if not si_account or posting_date < si_account.activation_date or \
1992- (si_account.inactivation_date and posting_date >= si_account.inactivation_date):
1993+ isi_journal_ids = journal_obj.search(cr, uid,
1994+ [('type', '=', 'purchase'), ('code', '=', 'ISI'), ('is_current_instance', '=', True)],
1995+ limit=1, context=context)
1996+ if not isi_journal_ids:
1997+ raise osv.except_osv(_('Error'), _("No Intersection Supplier Invoice journal found for the current instance."))
1998+ # for the ISI use the Account Payable of the partner
1999+ isi_account = partner.property_account_payable
2000+ if not isi_account or posting_date < isi_account.activation_date or \
2001+ (isi_account.inactivation_date and posting_date >= isi_account.inactivation_date):
2002 raise osv.except_osv(_('Error'), _("Account Payable not found or inactive for the partner %s.") % partner.name)
2003 vals.update(
2004 {
2005- 'journal_id': pur_journal_ids[0],
2006- 'account_id': si_account.id,
2007+ 'journal_id': isi_journal_ids[0],
2008+ 'account_id': isi_account.id,
2009 'type': 'in_invoice',
2010+ 'real_doc_type': 'isi',
2011 'is_direct_invoice': False,
2012 'is_inkind_donation': False,
2013 'is_debit_note': False,
2014@@ -249,6 +252,7 @@
2015 'journal_id': int_journal_ids[0],
2016 'account_id': ivi_account.id,
2017 'type': 'in_invoice',
2018+ 'real_doc_type': 'ivi',
2019 'is_inkind_donation': False,
2020 'is_debit_note': False,
2021 'is_intermission': True,
2022@@ -321,7 +325,7 @@
2023 if inv_id:
2024 self._create_invoice_lines(cr, uid, inv_lines, inv_id, posting_date, po, from_supply, context=context)
2025 if journal_type == 'sale':
2026- msg = "SI No. %s created successfully." % inv_id
2027+ msg = "ISI No. %s created successfully." % inv_id
2028 elif journal_type == 'intermission':
2029 msg = "IVI No. %s created successfully." % inv_id
2030 self._logger.info(msg)
2031@@ -352,7 +356,7 @@
2032 if counterpart_inv_number:
2033 inv_ids = self.search(cr, uid, [('number', '=', counterpart_inv_number)], limit=1, context=context)
2034 elif not counterpart_inv_number and number:
2035- # use case where the state of the IVO/STV is updated before the related IVI/SI has been opened
2036+ # use case where the state of the IVO/STV is updated before the related IVI/ISI has been opened
2037 inv_ids = self.search(cr, uid, [('counterpart_inv_number', '=', number)], limit=1, context=context)
2038 if inv_ids:
2039 self.write(cr, uid, inv_ids[0], vals, context=context)
2040
2041=== modified file 'bin/addons/account_override/account_invoice_view.xml'
2042--- bin/addons/account_override/account_invoice_view.xml 2021-04-29 10:12:12 +0000
2043+++ bin/addons/account_override/account_invoice_view.xml 2021-11-03 13:33:55 +0000
2044@@ -27,46 +27,6 @@
2045 </field>
2046 </record>
2047
2048- <!--
2049- Supplier Invoice
2050- -->
2051- <record id="invoice_supplier_form_3" model="ir.ui.view">
2052- <field name="name">account.invoice.supplier.form.3</field>
2053- <field name="model">account.invoice</field>
2054- <field name="type">form</field>
2055- <field name="inherit_id" ref="account.invoice_supplier_form"/>
2056- <field name="priority">20</field>
2057- <field name="arch" type="xml">
2058- <data>
2059- <xpath expr="/form/notebook/page[@string='Invoice']/field[@name='account_id']" position="attributes">
2060- <attribute name="domain">[('company_id', '=', company_id), ('restricted_area', '=', 'in_invoice')]</attribute>
2061- </xpath>
2062- <xpath expr="/form/group[1]/field[@name='partner_id']" position="attributes">
2063- <attribute name="on_change">onchange_partner_id(type,partner_id,date_invoice,payment_term,partner_bank_id,company_id,is_inkind_donation,is_intermission,is_debit_note,is_direct_invoice,False)</attribute>
2064- </xpath>
2065- <xpath expr="//tree[@string='Invoice lines']/field[@name='product_id']" position="before">
2066- <field name="line_number" displayon="noteditable"/>
2067- </xpath>
2068- <xpath expr="//field[@name='date_invoice']" position="before">
2069- <field name="document_date" />
2070- </xpath>
2071- <xpath expr="//field[@name='period_id']" position="replace">
2072- </xpath>
2073- <xpath expr="//label[@string='(keep empty to use the current period)']" position="replace">
2074- </xpath>
2075- <xpath expr="//button[@name='invoice_open']" position="after" >
2076- <button name="button_split_invoice" states="draft,proforma2" type="object" string="Split Invoice" icon="gtk-cut"/>
2077- <newline/>
2078- <field name="can_merge_lines" invisible="1"/>
2079- <button name="button_merge_lines" type="object"
2080- colspan="3"
2081- string="Merge Lines by Account" icon="gtk-convert"
2082- confirm="You are about to merge invoice lines; are you sure you want to proceed ? THIS OPERATION CAN NOT BE UNDONE"
2083- attrs="{'invisible': [('can_merge_lines', '!=', True)]}"/>
2084- </xpath>
2085- </data>
2086- </field>
2087- </record>
2088
2089 <!-- Change account_id domain -->
2090 <record id="invoice_line_form3" model="ir.ui.view">
2091@@ -82,131 +42,6 @@
2092 </field>
2093 </record>
2094
2095- <!--
2096- Delete some field from account_invoice tree:
2097- - Salesman or User (user_id)
2098- - Total amount (amount_total)
2099- - Untaxed (amount_untaxed)
2100- Add some elements:
2101- - Document date
2102- -->
2103- <record id="inherit_invoice_tree" model="ir.ui.view">
2104- <field name="name">inherit.invoice.tree</field>
2105- <field name="model">account.invoice</field>
2106- <field name="type">tree</field>
2107- <field name="inherit_id" ref="account.invoice_tree"/>
2108- <field name="priority">17</field>
2109- <field name="arch" type="xml">
2110- <data>
2111- <xpath expr="/tree/field[@name='date_invoice']" position="before">
2112- <field name="document_date"/>
2113- <field name="supplier_reference"/>
2114- </xpath>
2115- <xpath expr="/tree/field[@name='user_id']" position="replace">
2116- </xpath>
2117- <xpath expr="/tree/field[@name='amount_untaxed']" position="replace">
2118- </xpath>
2119- <xpath expr="/tree/field[@name='residual']" position="attributes">
2120- <attribute name="sum"></attribute>
2121- </xpath>
2122- <xpath expr="/tree/field[@name='amount_total']" position="attributes">
2123- <attribute name="sum"></attribute>
2124- </xpath>
2125- </data>
2126- </field>
2127- </record>
2128-
2129- <!--
2130- Delete some element from Search views:
2131- - Salesman or user (user_id)
2132- - Total (amount_total)
2133- - Responsible button (group by)
2134- - Proforma button
2135- - Invoices button
2136- - Unpaid button
2137- And add some ones:
2138- - Open button
2139- - Paid button
2140- -->
2141- <record id="inherit_view_account_invoice_filter" model="ir.ui.view">
2142- <field name="name">inherit.view.account.invoice.filter</field>
2143- <field name="model">account.invoice</field>
2144- <field name="type">search</field>
2145- <field name="inherit_id" ref="account.view_account_invoice_filter"/>
2146- <field name="priority">17</field>
2147- <field name="arch" type="xml">
2148- <data>
2149- <xpath expr="/search/group[1]/filter[@name='proforma']" position="replace">
2150- </xpath>
2151- <xpath expr="/search/group[1]/filter[@name='invoices']" position="replace">
2152- </xpath>
2153- <xpath expr="/search/group[1]/filter[@name='unpaid']" position="attributes">
2154- <attribute name="string">Open</attribute>
2155- <attribute name="help">Open Invoices</attribute>
2156- </xpath>
2157- <xpath expr="/search/group[1]/field[@name='user_id']" position="replace">
2158- </xpath>
2159- <xpath expr="/search/group[3]/filter[@string='Responsible']" position="replace">
2160- </xpath>
2161- <xpath expr="/search/group[2]/field[@name='period_id']" position="after">
2162- <field name="supplier_reference"/>
2163- <field name="name"/>
2164- </xpath>
2165- <xpath expr="/search/group[1]/separator[1]" position="replace">
2166- </xpath>
2167- <xpath expr="/search/group[1]/filter[@name='unpaid']" position="after">
2168- <filter name="paid" icon="terp-dolar" string="Paid" domain="[('state', '=', 'paid')]"/>
2169- <filter name="closed" icon="terp-dialog-close" string="Closed" domain="[('state', '=', 'inv_close')]" />
2170- <filter name="cancel_state" icon="terp-gtk-stop" string="Cancelled" domain="[('state', '=', 'cancel')]"/>
2171- <separator orientation="vertical"/>
2172- <filter name="not_imported" icon="gtk-cancel" string="Not imported" domain="[('imported_state', '=', 'not')]"/>
2173- <filter name="partial" icon="terp-dolar_ok!" string="Partially imported" domain="[('imported_state', '=', 'partial')]"/>
2174- <filter name="imported" icon="gtk-apply" string="Imported" domain="[('imported_state', '=', 'imported')]"/>
2175- <separator orientation="vertical"/>
2176- </xpath>
2177- </data>
2178- </field>
2179- </record>
2180-
2181- <!--
2182- Delete some elements from Stock transfer voucher (customer invoices):
2183- - period_id
2184- - label with "keep empty…"
2185- Add some others elements:
2186- - document_date
2187- -->
2188- <record id="invoice_form_4" model="ir.ui.view">
2189- <field name="name">account.invoice.supplier.form.4</field>
2190- <field name="model">account.invoice</field>
2191- <field name="type">form</field>
2192- <field name="inherit_id" ref="account.invoice_form"/>
2193- <field name="priority">22</field>
2194- <field name="arch" type="xml">
2195- <data>
2196- <xpath expr="//field[@name='date_invoice']" position="before">
2197- <field name="document_date"/>
2198- </xpath>
2199- <xpath expr="//field[@name='period_id']" position="replace">
2200- </xpath>
2201- <xpath expr="//label[@string='(keep empty to use the current period)']" position="replace">
2202- </xpath>
2203- </data>
2204- </field>
2205- </record>
2206-
2207- <!-- Add Split Invoice Button on invoices -->
2208- <record id="invoice_form_3" model="ir.ui.view">
2209- <field name="name">account.invoice.form.3</field>
2210- <field name="model">account.invoice</field>
2211- <field name="type">form</field>
2212- <field name="inherit_id" ref="account.invoice_form"/>
2213- <field name="priority">40</field>
2214- <field name="arch" type="xml">
2215- <button name='invoice_open' position="after">
2216- <button name="button_split_invoice" states="draft,proforma2" type="object" string="Split Invoice" icon="gtk-cut"/>
2217- </button>
2218- </field>
2219- </record>
2220
2221 <!--
2222 Debit Note views
2223@@ -245,7 +80,7 @@
2224 <field name="arch" type="xml">
2225 <form string="Debit Note" hide_duplicate_button="1">
2226 <group colspan="4" col="8">
2227- <field name="journal_id" domain="[('is_current_instance','=',True), ('type', '=', context.get('journal_type'))]"/>
2228+ <field name="journal_id" domain="[('inv_doc_type', '=', True)]"/>
2229 <field name="number"/>
2230 <field name="type" invisible="1"/>
2231 <field name="currency_id" width="50"/>
2232@@ -345,7 +180,7 @@
2233 <field name="arch" type="xml">
2234 <form string="In-kind Donation" noteditable="state=='cancel'">
2235 <group colspan="4" col="8">
2236- <field name="journal_id" domain="[('is_current_instance','=',True), ('type', 'in', ('inkind', 'extra'))]"/>
2237+ <field name="journal_id" domain="[('inv_doc_type', '=', True)]"/>
2238 <field name="number"/>
2239 <field name="type" invisible="1"/>
2240 <field name="is_inkind_donation" invisible="1"/>
2241@@ -508,7 +343,7 @@
2242 <field name="arch" type="xml">
2243 <form string="Intermission Voucher" noteditable="state=='cancel'">
2244 <group colspan="4" col="8">
2245- <field name="fake_journal_id" domain="[('is_current_instance','=',True)]" />
2246+ <field name="fake_journal_id"/> <!-- readonly -->
2247 <field name="journal_type" invisible="1"/>
2248 <field name="number"/>
2249 <field name="type" invisible="1"/>
2250@@ -747,113 +582,6 @@
2251 </record>
2252
2253 <!--
2254- Delete some elements on customer invoices:
2255- - fiscal_position field
2256- - proforma button (invoice_proforma2)
2257- - payment_term field
2258- - tax frame
2259- - compute tax button (button_reset_taxes)
2260- - amount untaxed field
2261- - amount tax field
2262- Update some other ones:
2263- - account_id field to add a domain on accounts regarding "ACCOUNT_RESTRICTED_AREA" variable
2264- -->
2265- <record id="inherit_invoice_form" model="ir.ui.view">
2266- <field name="name">inherit.invoice.form</field>
2267- <field name="model">account.invoice</field>
2268- <field name="type">form</field>
2269- <field name="inherit_id" ref="account.invoice_form"/>
2270- <field name="priority">61</field>
2271- <field name="arch" type="xml">
2272- <data>
2273- <xpath expr="/form" position="attributes">
2274- <attribute name="string">Stock Transfer Voucher</attribute>
2275- </xpath>
2276- <xpath expr="/form/notebook/page[@string='Invoice']/field[@name='account_id']" position="attributes">
2277- <attribute name="domain">[('company_id', '=', company_id), ('restricted_area', '=', 'out_invoice')]</attribute>
2278- </xpath>
2279- <field name="fiscal_position" position="replace"/>
2280- <field name="payment_term" position="replace"/>
2281- <field name="tax_line" position="replace"/>
2282- <button name="button_reset_taxes" position="replace"/>
2283- <button name="invoice_proforma2" position="replace"/>
2284- <xpath expr="/form/notebook/page[@string='Invoice']/field[@name='invoice_line']" position="before" >
2285- <group name="import" string=" Import Lines " colspan="4" col="4"
2286- attrs="{'invisible': [('state', '!=', 'draft'), ('type', '!=', 'out_invoice')]}">
2287- <button name="import_invoice" string="Import Invoice Line" icon="gtk-execute" colspan="2" type="object"
2288- attrs="{'readonly': [('state', '!=', 'draft')],
2289- 'invisible': [('type', '!=', 'out_invoice')]}"/>
2290- <button name="export_invoice" string="Export Invoice Line" icon="gtk-execute" colspan="2" type="object"
2291- attrs="{'invisible': [('type', '!=', 'out_invoice')]}"
2292- force_editable="1"/>
2293- <newline/>
2294- <button name="wizard_import_si_line" string="Import lines" icon="gtk-dnd" colspan="4" type="object"
2295- attrs="{'invisible': [('state', '!=', 'draft')],
2296- 'readonly': [('type', '=', 'out_invoice'),
2297- ('from_supply', '=', True),
2298- ('partner_type', 'in', ('intermission', 'section'))]}"/>
2299- </group>
2300- </xpath>
2301- <xpath expr="/form/notebook/page[@string='Invoice']/group[3]" position="replace">
2302- <group col="8" colspan="4">
2303- <label string="" colspan="3"/>
2304- <field name="reconciled"/>
2305- <field name="amount_total"/>
2306- <label string="" colspan="3"/>
2307- <field name="state"/>
2308- <field name="residual"/>
2309- <field name="is_debit_note" invisible="1"/>
2310- </group>
2311- <field name="partner_type" invisible="1"/>
2312- <group col="8" colspan="4">
2313-
2314- <button string="Cancel document" name="invoice_cancel"
2315- type="workflow" icon="gtk-cancel"
2316- confirm="Do you really want to cancel this document?"
2317- attrs="{'invisible': ['|', '|',
2318- ('state', '!=', 'draft'),
2319- ('type', '!=', 'out_invoice'),
2320- ('from_supply', '=', False)]}"/>
2321-
2322- <button name="button_split_invoice" type="object" string="Split Stock Transfer Voucher"
2323- icon="gtk-cut"
2324- context="{'from_stv': True}"
2325- attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('type', '!=', 'out_invoice')]}"/>
2326-
2327- <button name="%(account.action_account_invoice_refund)d" type='action' string='Refund' icon="gtk-execute" attrs="{'invisible': ['|', ('state', 'in', ['draft']), ('type', 'in', ['in_refund', 'out_refund'])]}"/>
2328- <!-- add a confirmation step only for STV (not for Customer Refunds)
2329- when the partner type is compatible with a synchro but "synced" isn't ticked -->
2330- <button name="invoice_open" type="object" string="Validate"
2331- icon="gtk-go-forward"
2332- attrs="{'invisible': ['|',
2333- ('state', '!=', 'draft'),
2334- '&amp;',
2335- ('type', '=', 'out_invoice'), ('partner_type', 'in', ('intermission', 'section')) ]}"/>
2336- <button name="invoice_open_with_confirmation" type="object" string="Validate"
2337- icon="gtk-go-forward"
2338- confirm="Are you sure you want to validate this invoice without synchronization?"
2339- attrs="{'invisible': ['|', '|', '|',
2340- ('state', '!=', 'draft'),
2341- ('type', '!=', 'out_invoice'),
2342- ('synced', '=', True),
2343- ('partner_type', 'not in', ('intermission', 'section'))]}"/>
2344-
2345- <button name="invoice_open_with_sync_confirmation" type="object" string="Validate"
2346- icon="gtk-go-forward"
2347- confirm="This invoice will sync to its counterpart instance."
2348- attrs="{'invisible': ['|', '|', '|',
2349- ('state', '!=', 'draft'),
2350- ('type', '!=', 'out_invoice'),
2351- ('synced', '=', False),
2352- ('partner_type', 'not in', ('intermission', 'section'))]}"/>
2353- <button name="%(account.account_invoices)d" string="Print Invoice" type="action" icon="gtk-print" states="open,paid,inv_close,proforma,sale,proforma2"/>
2354- </group>
2355- </xpath>
2356- </data>
2357- </field>
2358- </record>
2359-
2360- <!--
2361 Debit note actions
2362 -->
2363
2364@@ -864,8 +592,8 @@
2365 <field name="view_type">form</field>
2366 <field name="view_mode">tree,form,calendar,graph</field>
2367 <field eval="False" name="view_id"/>
2368- <field name="domain">[('type','=','out_invoice'), ('is_debit_note', '!=', False), ('is_inkind_donation', '=', False)]</field>
2369- <field name="context">{'type':'out_invoice', 'journal_type': 'sale', 'is_debit_note': True}</field>
2370+ <field name="domain">[('doc_type', '=', 'dn')]</field>
2371+ <field name="context">{'doc_type': 'dn', 'type': 'out_invoice', 'journal_type': 'sale', 'is_debit_note': True}</field>
2372 <field name="search_view_id" ref="account.view_account_invoice_filter"/>
2373 </record>
2374
2375@@ -931,8 +659,8 @@
2376 <field name="view_type">form</field>
2377 <field name="view_mode">tree,form,calendar,graph</field>
2378 <field eval="False" name="view_id"/>
2379- <field name="domain">[('type','=','in_invoice'), ('is_debit_note', '=', False), ('is_inkind_donation', '=', True)]</field>
2380- <field name="context">{'type': 'in_invoice', 'journal_type': 'inkind', 'is_inkind_donation': '1', 'from_inv_form': True, 'search_default_draft': 1, 'search_default_open': 1}</field>
2381+ <field name="domain">[('doc_type', '=', 'donation')]</field>
2382+ <field name="context">{'doc_type': 'donation', 'type': 'in_invoice', 'journal_type': 'inkind', 'is_inkind_donation': '1', 'from_inv_form': True, 'search_default_draft': 1, 'search_default_open': 1}</field>
2383 <field name="search_view_id" ref="view_account_invoice_filter_donation"/>
2384 </record>
2385
2386@@ -959,8 +687,8 @@
2387 <field name="view_type">form</field>
2388 <field name="view_mode">tree,form,calendar,graph</field>
2389 <field eval="False" name="view_id"/>
2390- <field name="domain">[('type','=','out_invoice'), ('is_debit_note', '=', False), ('is_inkind_donation', '=', False), ('is_intermission', '=', True)]</field>
2391- <field name="context">{'type': 'out_invoice', 'journal_type': 'intermission', 'is_intermission': True, 'intermission_type': 'out', 'from_inv_form': True, 'search_default_draft': 1, 'search_default_unpaid': 1, 'search_default_paid': 1, 'search_default_closed': 1}</field>
2392+ <field name="domain">[('doc_type', '=', 'ivo')]</field>
2393+ <field name="context">{'doc_type': 'ivo', 'type': 'out_invoice', 'journal_type': 'intermission', 'is_intermission': True, 'intermission_type': 'out', 'from_inv_form': True, 'search_default_draft': 1, 'search_default_unpaid': 1, 'search_default_paid': 1, 'search_default_closed': 1}</field>
2394 <field name="search_view_id" ref="account.view_account_invoice_filter"/>
2395 </record>
2396
2397@@ -987,8 +715,8 @@
2398 <field name="view_type">form</field>
2399 <field name="view_mode">tree,form,calendar,graph</field>
2400 <field name="view_id" ref="view_intermission_form"/>
2401- <field name="domain">[('type','=','in_invoice'), ('is_debit_note', '=', False), ('is_inkind_donation', '=', False), ('is_intermission', '=', True)]</field>
2402- <field name="context">{'type':'in_invoice', 'journal_type': 'intermission', 'is_intermission': True, 'intermission_type': 'in', 'from_inv_form': True}</field>
2403+ <field name="domain">[('doc_type', '=', 'ivi')]</field>
2404+ <field name="context">{'doc_type': 'ivi', 'type': 'in_invoice', 'journal_type': 'intermission', 'is_intermission': True, 'intermission_type': 'in', 'from_inv_form': True}</field>
2405 <field name="search_view_id" ref="account.view_account_invoice_filter"/>
2406 </record>
2407
2408@@ -1008,34 +736,6 @@
2409 <field name="act_window_id" ref="action_intermission_in"/>
2410 </record>
2411
2412- <!-- Fix customer invoice display with a bypass on 'is_debit_note' set to True -->
2413- <record id="account.action_invoice_tree1" model="ir.actions.act_window">
2414- <field name="name">Customer Invoices</field> <!-- Stock Transfer Vouchers -->
2415- <field name="res_model">account.invoice</field>
2416- <field name="view_type">form</field>
2417- <field name="view_mode">tree,form,calendar,graph</field>
2418- <field eval="False" name="view_id"/>
2419- <field name="domain">[('type','=','out_invoice'), ('is_debit_note', '=', False), ('is_inkind_donation', '=', False), ('is_intermission', '=', False)]</field>
2420- <field name="context">{'type':'out_invoice', 'journal_type': 'sale', 'from_inv_form': True, 'search_default_draft': 1, 'search_default_unpaid': 1, 'search_default_paid': 1, 'search_default_closed': 1}</field>
2421- <field name="search_view_id" ref="account.view_account_invoice_filter"/>
2422- <field name="help">With Customer Invoices you can create and manage sales invoices issued to your customers. OpenERP can also generate draft invoices automatically from sales orders or deliveries. You should only confirm them before sending them to your customers.</field>
2423- </record>
2424-
2425- <!-- Fix supplier invoice display with a bypass on 'is_inkind_donation' set to True -->
2426- <record id="account.action_invoice_tree2" model="ir.actions.act_window">
2427- <field name="name">Supplier Invoices</field>
2428- <field name="res_model">account.invoice</field>
2429- <field name="view_type">form</field>
2430- <field name="view_mode">tree,form,calendar,graph</field>
2431- <field eval="False" name="view_id"/>
2432- <!-- US-2704 if the domain change, do not forget to update the domain of account_board_supplier_invoice_draft in finance/board_account_view.xml -->
2433- <field name="domain">[('type','=','in_invoice'), ('is_direct_invoice', '=', False), ('is_inkind_donation', '=', False), ('is_debit_note', "=", False), ('is_intermission', '=', False)]</field>
2434- <field name="context">{'type': 'in_invoice', 'journal_type': 'purchase', 'from_inv_form': True}</field>
2435- <field name="search_view_id" ref="account.view_account_invoice_filter"/>
2436- <field name="help">With Supplier Invoices you can enter and manage invoices issued by your suppliers.
2437- OpenERP can also generate draft invoices automatically from purchase orders or receipts. This way, you can control the invoice
2438- from your supplier according to what you purchased or received.</field>
2439- </record>
2440
2441 <!--
2442 Debit Note Menu
2443@@ -1045,13 +745,13 @@
2444 <menuitem action="action_debit_note" id="menu_action_debit_note" parent="account.menu_finance_receivables" sequence="10"/>
2445
2446 <!-- In-kind Donation Menu in "Supplier Invoices" -->
2447- <menuitem action="action_inkind_donation" id="menu_action_inkind_donation" parent="account.menu_finance_payables" sequence="11"/>
2448+ <menuitem action="action_inkind_donation" id="menu_action_inkind_donation" parent="account.menu_finance_payables" sequence="30"/>
2449
2450 <!-- Intermission Voucher OUT in "Customer Invoices" -->
2451- <menuitem action="action_intermission_out" id="menu_action_intermission_out" parent="account.menu_finance_receivables" sequence="10"/>
2452+ <menuitem action="action_intermission_out" id="menu_action_intermission_out" parent="account.menu_finance_receivables" sequence="12"/>
2453
2454 <!-- Intermission Voucher IN in "Supplier Invoices" -->
2455- <menuitem action="action_intermission_in" id="menu_action_intermission_in" parent="account.menu_finance_payables" sequence="12"/>
2456+ <menuitem action="action_intermission_in" id="menu_action_intermission_in" parent="account.menu_finance_payables" sequence="40"/>
2457
2458 <!--
2459 Account invoice report redefinition
2460
2461=== modified file 'bin/addons/account_override/account_view.xml'
2462--- bin/addons/account_override/account_view.xml 2019-06-18 11:15:45 +0000
2463+++ bin/addons/account_override/account_view.xml 2021-11-03 13:33:55 +0000
2464@@ -2,61 +2,6 @@
2465 <openerp>
2466 <data>
2467
2468- <record model="ir.ui.view" id="view_account_activable_form">
2469- <field name="name">account.account_activable.form</field>
2470- <field name="model">account.account</field>
2471- <field name="type">form</field>
2472- <field name="inherit_id" ref="account.view_account_form"/>
2473- <field name="priority">20</field>
2474- <field name="arch" type="xml">
2475- <field name="company_id" position="replace"/>
2476- <page string="General Information" position="replace">
2477- <page string="General Information">
2478- <group col="6" colspan="4">
2479- <field name="activation_date"/>
2480- <field name="inactivation_date"/>
2481- <group col="2" colspan="2">
2482- <field name="reconcile" on_change="onchange_reconcile(reconcile)"/>
2483- <field name="prevent_multi_curr_rec" attrs="{'readonly': [('reconcile', '=', False)]}"/>
2484- <field name="reconciliation_debit_account_id"/>
2485- <field name="reconciliation_credit_account_id"/>
2486- </group>
2487- </group>
2488- </page>
2489- </page>
2490-
2491- <page string="Notes" position="before">
2492- <page string="Allowed Partner types">
2493- <group col="4" colspan="4">
2494- <group col="2" colspan="2">
2495- <field name="has_partner_type_internal" />
2496- <field name="has_partner_type_external" />
2497- <field name="has_partner_type_esc" />
2498- <newline />
2499- <field name="has_partner_type_local" />
2500- <field name="has_partner_type_ex" />
2501- <field name="has_partner_type_empty" />
2502- <newline />
2503- <field name="has_partner_type_book" />
2504- </group>
2505-
2506- <group col="2" colspan="2">
2507- <field name="has_partner_type_intermission" />
2508- <field name="has_partner_type_section" />
2509-
2510- <label /><label />
2511- <newline />
2512- <label /><label />
2513- <label /><label />
2514- <newline />
2515- <label /><label />
2516- </group>
2517- </group>
2518- </page>
2519- </page>
2520- </field>
2521- </record>
2522-
2523 <!-- Tree view for Balance by Account result: granularity by parent account -->
2524 <record model="ir.ui.view" id="balance_account_tree">
2525 <field name="name">balance.account.tree</field>
2526@@ -99,46 +44,6 @@
2527 </field>
2528 </record>
2529
2530- <!-- Tree view for chart of account result -->
2531- <record model="ir.ui.view" id="account.view_account_tree">
2532- <field name="name">account.account_activable.tree</field>
2533- <field name="model">account.account</field>
2534- <field name="type">tree</field>
2535- <field name="field_parent">child_id</field>
2536- <field name="priority" eval="12"/>
2537- <field name="arch" type="xml">
2538- <tree colors="blue:type in ('view');black:type in ('other','receivable','payable','consolidation');gray:type in ('closed')" string="Chart of accounts" toolbar="1" expand_button="1" nolink="1">
2539- <field name="code"/>
2540- <field name="name"/>
2541- <field name="note"/>
2542- <field name="type" invisible="1"/>
2543- <field name="user_type" invisible="1"/>
2544- <field name="activation_date" invisible="1"/>
2545- <field name="inactivation_date" invisible="1"/>
2546- <field name="parent_id" invisible="1"/>
2547- <field name="is_analytic_addicted" invisible="1"/>
2548- </tree>
2549- </field>
2550- </record>
2551-
2552- <!-- Tree view for default tree view of accounts -->
2553- <record id="account.view_account_list" model="ir.ui.view">
2554- <field name="name">account.account_activable.list</field>
2555- <field name="model">account.account</field>
2556- <field name="type">tree</field>
2557- <field name="field_parent">child_id</field>
2558- <field name="priority" eval="10"/>
2559- <field name="arch" type="xml">
2560- <tree colors="blue:type in ('view');black:type in ('other','receivable','payable','consolidation');gray:type in ('closed')" string="Chart of accounts" toolbar="1" nolink="1">
2561- <field name="code"/>
2562- <field name="name"/>
2563- <field name="type"/>
2564- <field name="activation_date"/>
2565- <field name="inactivation_date"/>
2566- </tree>
2567- </field>
2568- </record>
2569-
2570 <record id="action_account_activable_form" model="ir.actions.act_window">
2571 <field name="name">Accounts</field>
2572 <field name="res_model">account.account</field>
2573
2574=== modified file 'bin/addons/account_override/invoice.py'
2575--- bin/addons/account_override/invoice.py 2021-08-11 15:37:51 +0000
2576+++ bin/addons/account_override/invoice.py 2021-11-03 13:33:55 +0000
2577@@ -26,7 +26,6 @@
2578 from osv import fields
2579 from time import strftime
2580 from tools.translate import _
2581-from lxml import etree
2582 from datetime import datetime
2583 from msf_partner import PARTNER_TYPE
2584 import re
2585@@ -51,55 +50,40 @@
2586 inv_name = inv.number or inv.name or 'No_description'
2587 prefix = 'STV_'
2588
2589- if inv.type == 'out_refund': # Customer refund
2590+ if inv.doc_type == 'cr':
2591 prefix = 'CR_'
2592- elif inv.type == 'in_refund': # Supplier refund
2593+ elif inv.doc_type == 'sr':
2594 prefix = 'SR_'
2595- elif inv.type == 'out_invoice':
2596- # Stock transfer voucher
2597+ elif inv.doc_type == 'stv':
2598 prefix = 'STV_'
2599- # Debit note
2600- if inv.is_debit_note and not inv.is_inkind_donation and not inv.is_intermission:
2601- prefix = 'DN_'
2602- # Intermission voucher OUT
2603- elif not inv.is_debit_note and not inv.is_inkind_donation and inv.is_intermission:
2604- prefix = 'IVO_'
2605- elif inv.type == 'in_invoice':
2606- # Supplier invoice
2607+ elif inv.doc_type == 'dn':
2608+ prefix = 'DN_'
2609+ elif inv.doc_type == 'ivo':
2610+ prefix = 'IVO_'
2611+ elif inv.doc_type == 'si':
2612 prefix = 'SI_'
2613- # Intermission voucher IN
2614- if not inv.is_debit_note and not inv.is_inkind_donation and inv.is_intermission:
2615- prefix = 'IVI_'
2616- # Direct invoice
2617- elif inv.is_direct_invoice:
2618- prefix = 'DI_'
2619- # In-kind donation
2620- elif not inv.is_debit_note and inv.is_inkind_donation:
2621- prefix = 'DON_'
2622+ elif inv.doc_type == 'ivi':
2623+ prefix = 'IVI_'
2624+ elif inv.doc_type == 'di':
2625+ prefix = 'DI_'
2626+ elif inv.doc_type == 'donation':
2627+ prefix = 'DON_'
2628+ elif inv.doc_type == 'str':
2629+ prefix = 'STR_'
2630+ elif inv.doc_type == 'isi':
2631+ prefix = 'ISI_'
2632+ elif inv.doc_type == 'isr':
2633+ prefix = 'ISR_'
2634 return '%s%s' % (prefix, inv_name)
2635
2636 def _get_journal(self, cr, uid, context=None):
2637 """
2638- WARNING: This method has been taken from account module from OpenERP
2639+ Returns the journal to be used by default, depending on the doc type of the selected invoice
2640 """
2641- # @@@override@account.invoice.py
2642 if context is None:
2643 context = {}
2644- user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
2645- if context.get('is_inkind_donation'):
2646- args = [('type', 'in', ['inkind', 'extra'])]
2647- else:
2648- type_inv = context.get('type', 'out_invoice')
2649- company_id = context.get('company_id', user.company_id.id)
2650- type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale_refund', 'in_refund': 'purchase_refund'}
2651- refund_journal = {'out_invoice': False, 'in_invoice': False, 'out_refund': True, 'in_refund': True}
2652- args = [('type', '=', type2journal.get(type_inv, 'sale')),
2653- ('company_id', '=', company_id),
2654- ('refund_journal', '=', refund_journal.get(type_inv, False))]
2655- if user.company_id.instance_id:
2656- args.append(('is_current_instance','=',True))
2657 journal_obj = self.pool.get('account.journal')
2658- res = journal_obj.search(cr, uid, args, order='id', limit=1, context=context)
2659+ res = journal_obj.search(cr, uid, [('inv_doc_type', '=', True)], order='id', limit=1, context=context)
2660 return res and res[0] or False
2661
2662 def _get_fake(self, cr, uid, ids, field_name=None, arg=None, context=None):
2663@@ -209,14 +193,10 @@
2664 ids = [ids]
2665
2666 for inv_br in self.browse(cr, uid, ids, context=context):
2667- # US-357: allow merge of line only for draft SI
2668+ # allow to merge lines only for draft SI/ISI
2669 res[inv_br.id] = inv_br.state and inv_br.state == 'draft' \
2670 and inv_br.invoice_line \
2671- and inv_br.type == 'in_invoice' \
2672- and not inv_br.is_direct_invoice \
2673- and not inv_br.is_inkind_donation \
2674- and not inv_br.is_debit_note \
2675- and not inv_br.is_intermission \
2676+ and inv_br.doc_type in ('si', 'isi') \
2677 or False
2678
2679 return res
2680@@ -234,6 +214,158 @@
2681 res[inv.id] = len(inv.invoice_line)
2682 return res
2683
2684+ def _get_invoice_type_list(self, cr, uid, context=None):
2685+ """
2686+ Returns the list of possible types for the account.invoice document.
2687+ """
2688+ return [('dn', _('Debit Note')),
2689+ ('donation', _('Donation')),
2690+ ('ivi', _('Intermission Voucher IN')),
2691+ ('ivo', _('Intermission Voucher OUT')),
2692+ ('di', _('Direct Invoice')),
2693+ ('si', _('Supplier Invoice')),
2694+ ('sr', _('Supplier Refund')),
2695+ ('stv', _('Stock Transfer Voucher')),
2696+ ('cr', _('Customer Refund')),
2697+ ('str', _('Stock Transfer Refund')),
2698+ ('isi', _('Intersection Supplier Invoice')),
2699+ ('isr', _('Intersection Supplier Refund')),
2700+ ('unknown', _('Unknown')),
2701+ ]
2702+
2703+ _invoice_action_act_window = {
2704+ 'dn': 'account_override.action_debit_note',
2705+ 'donation': 'account_override.action_inkind_donation',
2706+ 'ivi': 'account_override.action_intermission_in',
2707+ 'ivo': 'account_override.action_intermission_out',
2708+ 'di': 'register_accounting.action_direct_invoice',
2709+ 'si': 'account.action_invoice_tree2',
2710+ 'sr': 'account.action_invoice_tree4',
2711+ 'stv': 'account.action_invoice_tree1',
2712+ 'cr': 'account.action_invoice_tree3',
2713+ 'str': 'account.action_str',
2714+ 'isi': 'account.action_isi',
2715+ 'isr': 'account.action_isr',
2716+ }
2717+
2718+ def _get_invoice_act_window(self, cr, uid, invoice_id, views_order=None, context=None):
2719+ inv_doc_type = self.read(cr, uid, invoice_id, ['doc_type'], context=context)['doc_type']
2720+ return self.pool.get('ir.actions.act_window').open_view_from_xmlid(cr, uid, self._invoice_action_act_window[inv_doc_type], views_order=views_order, context=context)
2721+
2722+ def _get_doc_type(self, cr, uid, ids, field_name=None, arg=None, context=None):
2723+ """
2724+ Returns a dict with key = id of the account.invoice, and value = doc type (see the list of types in _get_invoice_type_list).
2725+ If a "real_doc_type" exists: it is used. Otherwise: the doc type is deduced from the other fields.
2726+ """
2727+ res = {}
2728+ fields = ['real_doc_type', 'type', 'is_debit_note', 'is_inkind_donation', 'is_intermission', 'is_direct_invoice']
2729+ for inv in self.browse(cr, uid, ids, fields_to_fetch=fields, context=context):
2730+ inv_type = 'unknown'
2731+ if inv.real_doc_type: # str, isi, isr...
2732+ inv_type = inv.real_doc_type
2733+ elif inv.is_debit_note:
2734+ if inv.type == 'out_invoice':
2735+ inv_type = 'dn' # Debit Note
2736+ elif inv.is_inkind_donation:
2737+ if inv.type == 'in_invoice':
2738+ inv_type = 'donation'
2739+ elif inv.is_intermission:
2740+ if inv.type == 'in_invoice':
2741+ inv_type = 'ivi' # Intermission Voucher In
2742+ elif inv.type == 'out_invoice':
2743+ inv_type = 'ivo' # Intermission Voucher Out
2744+ elif inv.type == 'in_invoice':
2745+ if inv.is_direct_invoice:
2746+ inv_type = 'di' # Direct Invoice
2747+ else:
2748+ inv_type = 'si' # Supplier Invoice
2749+ elif inv.type == 'in_refund':
2750+ inv_type = 'sr' # Supplier Refund
2751+ elif inv.type == 'out_invoice':
2752+ inv_type = 'stv' # Stock Transfer Voucher
2753+ elif inv.type == 'out_refund':
2754+ inv_type = 'cr' # Customer Refund
2755+ res[inv.id] = inv_type
2756+ return res
2757+
2758+ def _get_dom_by_doc_type(self, doc_type):
2759+ """
2760+ Returns the domain matching with the doc type (see the list of types in _get_invoice_type_list).
2761+ """
2762+ if doc_type in ('str', 'isi', 'isr'):
2763+ dom = [('real_doc_type', '=', doc_type)]
2764+ elif doc_type == 'dn': # Debit Note
2765+ dom = ['|',
2766+ ('real_doc_type', '=', doc_type),
2767+ '&', '&', '&',
2768+ ('real_doc_type', '=', False), ('type', '=', 'out_invoice'),
2769+ ('is_debit_note', '!=', False), ('is_inkind_donation', '=', False)]
2770+ elif doc_type == 'donation':
2771+ dom = ['|',
2772+ ('real_doc_type', '=', doc_type),
2773+ '&', '&', '&',
2774+ ('real_doc_type', '=', False), ('type', '=', 'in_invoice'),
2775+ ('is_debit_note', '=', False), ('is_inkind_donation', '=', True)]
2776+ elif doc_type == 'ivi': # Intermission Voucher In
2777+ dom = ['|',
2778+ ('real_doc_type', '=', doc_type),
2779+ '&', '&', '&', '&',
2780+ ('real_doc_type', '=', False), ('type', '=', 'in_invoice'), ('is_debit_note', '=', False),
2781+ ('is_inkind_donation', '=', False), ('is_intermission', '=', True)]
2782+ elif doc_type == 'ivo': # Intermission Voucher Out
2783+ dom = ['|',
2784+ ('real_doc_type', '=', doc_type),
2785+ '&', '&', '&', '&',
2786+ ('real_doc_type', '=', False), ('type', '=', 'out_invoice'), ('is_debit_note', '=', False),
2787+ ('is_inkind_donation', '=', False), ('is_intermission', '=', True)]
2788+ elif doc_type == 'di': # Direct Invoice
2789+ dom = ['|',
2790+ ('real_doc_type', '=', doc_type),
2791+ '&', '&', ('real_doc_type', '=', False), ('type', '=', 'in_invoice'), ('is_direct_invoice', '!=', False)]
2792+ elif doc_type == 'si': # Supplier Invoice
2793+ dom = ['|',
2794+ ('real_doc_type', '=', doc_type),
2795+ '&', '&', '&', '&', '&',
2796+ ('real_doc_type', '=', False), ('type', '=', 'in_invoice'), ('is_direct_invoice', '=', False),
2797+ ('is_inkind_donation', '=', False), ('is_debit_note', '=', False), ('is_intermission', '=', False)]
2798+ elif doc_type == 'sr': # Supplier Refund
2799+ dom = ['|',
2800+ ('real_doc_type', '=', doc_type),
2801+ '&', ('real_doc_type', '=', False), ('type', '=', 'in_refund')]
2802+ elif doc_type == 'stv': # Stock Transfer Voucher
2803+ dom = ['|',
2804+ ('real_doc_type', '=', doc_type),
2805+ '&', '&', '&', '&',
2806+ ('real_doc_type', '=', False), ('type', '=', 'out_invoice'), ('is_debit_note', '=', False),
2807+ ('is_inkind_donation', '=', False), ('is_intermission', '=', False)]
2808+ elif doc_type == 'cr': # Customer Refund
2809+ dom = ['|',
2810+ ('real_doc_type', '=', doc_type),
2811+ '&', ('real_doc_type', '=', False), ('type', '=', 'out_refund')]
2812+ else: # "unknown" or any undefined type
2813+ dom = [('id', '=', 0)]
2814+ return dom
2815+
2816+ def _search_doc_type(self, cr, uid, obj, name, args, context=None):
2817+ """
2818+ Returns a domain to get all invoices matching the selected doc types (see the list of types in _get_invoice_type_list).
2819+ """
2820+ if not args:
2821+ return []
2822+ dom = [('id', '=', 0)]
2823+ if not args[0] or len(args[0]) < 3 or args[0][1] not in ('=', 'in'):
2824+ raise osv.except_osv(_('Error'), _('Filter not implemented yet.'))
2825+ if args[0][1] == '=' and args[0][2]:
2826+ doc_type = args[0][2]
2827+ dom = self._get_dom_by_doc_type(doc_type)
2828+ if args[0][1] == 'in' and args[0][2] and isinstance(args[0][2], (list, tuple)):
2829+ dom = []
2830+ for i in range(len(args[0][2]) - 1):
2831+ dom.append('|')
2832+ for doc_type in args[0][2]:
2833+ dom.extend(self._get_dom_by_doc_type(doc_type))
2834+ return dom
2835+
2836 _columns = {
2837 'sequence_id': fields.many2one('ir.sequence', string='Lines Sequence', ondelete='cascade',
2838 help="This field contains the information related to the numbering of the lines of this order."),
2839@@ -271,6 +403,9 @@
2840 'refunded_invoice_id': fields.many2one('account.invoice', string='Refunded Invoice', readonly=True,
2841 help='The refunded invoice which has generated this document'), # 2 inv types for Refund Modify
2842 'line_count': fields.function(_get_line_count, string='Line count', method=True, type='integer', store=False),
2843+ 'real_doc_type': fields.selection(_get_invoice_type_list, 'Real Document Type', readonly=True),
2844+ 'doc_type': fields.function(_get_doc_type, method=True, type='selection', selection=_get_invoice_type_list,
2845+ string='Document Type', store=False, fnct_search=_search_doc_type),
2846 }
2847
2848 _defaults = {
2849@@ -283,6 +418,8 @@
2850 'vat_ok': lambda obj, cr, uid, context: obj.pool.get('unifield.setup.configuration').get_config(cr, uid).vat_ok,
2851 'can_merge_lines': lambda *a: False,
2852 'is_merged_by_account': lambda *a: False,
2853+ # set a default value on doc type so that the restrictions on fields apply even before the form is saved
2854+ 'doc_type': lambda obj, cr, uid, c: c and c.get('doc_type') or False,
2855 }
2856
2857 def import_data_web(self, cr, uid, fields, datas, mode='init', current_module='', noupdate=False, context=None, filename=None,
2858@@ -420,30 +557,6 @@
2859 noupdate=noupdate, context=context, filename=filename,
2860 display_all_errors=display_all_errors, has_header=has_header)
2861
2862- def onchange_company_id(self, cr, uid, ids, company_id, part_id, ctype, invoice_line, currency_id):
2863- """
2864- This is a method to redefine the journal_id domain with the current_instance taken into account
2865- """
2866- res = super(account_invoice, self).onchange_company_id(cr, uid, ids, company_id, part_id, ctype, invoice_line, currency_id)
2867- if company_id and ctype:
2868- res.setdefault('domain', {})
2869- res.setdefault('value', {})
2870- ass = {
2871- 'out_invoice': 'sale',
2872- 'in_invoice': 'purchase',
2873- 'out_refund': 'sale_refund',
2874- 'in_refund': 'purchase_refund',
2875- }
2876- journal_ids = self.pool.get('account.journal').search(cr, uid, [
2877- ('company_id','=',company_id), ('type', '=', ass.get(ctype, 'purchase')), ('is_current_instance', '=', True)
2878- ], order='id')
2879- if not journal_ids:
2880- raise osv.except_osv(_('Configuration Error !'), _('Can\'t find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Financial Accounting\Accounts\Journals.') % (ass.get(type, 'purchase'), ))
2881- res['value']['journal_id'] = journal_ids[0]
2882- # TODO: it's very bad to set a domain by onchange method, no time to rewrite UniField !
2883- res['domain']['journal_id'] = [('id', 'in', journal_ids)]
2884- return res
2885-
2886 def onchange_partner_id(self, cr, uid, ids, ctype, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False,
2887 company_id=False, is_inkind_donation=False, is_intermission=False, is_debit_note=False, is_direct_invoice=False,
2888 account_id=False):
2889@@ -522,58 +635,27 @@
2890
2891 def check_po_link(self, cr, uid, ids, context=None):
2892 """
2893- Check that invoice (only supplier invoices) has no link with a PO. This is because of commitments presence.
2894+ Checks that the invoices aren't linked to any PO (because of the commitments).
2895 """
2896 if not context:
2897 context = {}
2898 if isinstance(ids, (int, long)):
2899 ids = [ids]
2900- for inv in self.read(cr, uid, ids, ['purchase_ids', 'type', 'is_inkind_donation', 'is_debit_note', 'is_intermission', 'state']):
2901- if inv.get('type', '') == 'in_invoice' and not inv.get('is_inkind_donation', False) and not inv.get('is_debit_note', False):
2902+ for inv in self.read(cr, uid, ids, ['purchase_ids', 'doc_type', 'state']):
2903+ if inv.get('doc_type', '') in ('ivi', 'si', 'isi'):
2904 if inv.get('purchase_ids', False):
2905- if inv.get('is_intermission'):
2906+ if inv['doc_type'] == 'ivi':
2907 if inv.get('state', '') != 'draft': # only draft IVIs can be deleted
2908 raise osv.except_osv(_('Warning'),
2909 _('Intermission Vouchers linked to a PO can be deleted only in Draft state.'))
2910+ elif inv['doc_type'] == 'isi':
2911+ raise osv.except_osv(_('Warning'),
2912+ _('You cannot cancel or delete an Intersection Supplier Invoice linked to a PO.'))
2913 else:
2914 # US-1702 Do not allow at all the deletion of SI coming from PO
2915 raise osv.except_osv(_('Warning'), _('You cannot cancel or delete a supplier invoice linked to a PO.'))
2916 return True
2917
2918-
2919- def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
2920- """
2921- Rename Supplier/Customer to "Donor" if view_type == tree
2922- """
2923- if not context:
2924- context = {}
2925- res = super(account_invoice, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
2926- if view_type == 'tree' and (context.get('journal_type', False) == 'inkind' or context.get('journal_type', False) == 'intermission'):
2927- doc = etree.XML(res['arch'])
2928- nodes = doc.xpath("//field[@name='partner_id']")
2929- name = _('Donor')
2930- if context.get('journal_type') == 'intermission':
2931- name = _('Partner')
2932- for node in nodes:
2933- node.set('string', name)
2934- res['arch'] = etree.tostring(doc)
2935- elif view_type in ('tree', 'search') and context.get('type') in ['out_invoice', 'out_refund']:
2936- doc = etree.XML(res['arch'])
2937- nodes = doc.xpath("//field[@name='supplier_reference']")
2938- for node in nodes:
2939- node.getparent().remove(node)
2940- res['arch'] = etree.tostring(doc)
2941- elif view_type == 'form' and context.get('type', False) == 'out_invoice' and context.get('journal_type', False) == 'sale' \
2942- and not context.get('is_debit_note', False) and not context.get('is_intermission', False):
2943- # Restriction on allowed partners for STV: Inter-section or External type, customers only
2944- doc = etree.XML(res['arch'])
2945- partner_nodes = doc.xpath("//field[@name='partner_id']")
2946- partner_domain_stv = "[('partner_type', 'in', ('section', 'external')), ('customer', '=', True)]"
2947- for node in partner_nodes:
2948- node.set('domain', partner_domain_stv)
2949- res['arch'] = etree.tostring(doc)
2950- return res
2951-
2952 def default_get(self, cr, uid, fields, context=None, from_web=False):
2953 """
2954 Fill in account and journal for intermission invoice
2955@@ -704,6 +786,9 @@
2956 context=context):
2957 vals['supplier_reference'] = partner['ref']
2958
2959+ if not vals.get('real_doc_type') and context.get('doc_type') and not context.get('from_refund_button'):
2960+ vals.update({'real_doc_type': context['doc_type']})
2961+
2962 self.pool.get('data.tools').replace_line_breaks_from_vals(vals, ['name'])
2963
2964 return super(account_invoice, self).create(cr, uid, vals, context)
2965@@ -742,7 +827,7 @@
2966 def unlink(self, cr, uid, ids, context=None):
2967 """
2968 Delete register line if this invoice is a Direct Invoice.
2969- Don't delete an invoice that is linked to a PO. This is only for supplier invoices.
2970+ Don't delete an invoice that is linked to a PO.
2971 """
2972 if not context:
2973 context = {}
2974@@ -783,65 +868,20 @@
2975
2976 def log(self, cr, uid, inv_id, message, secondary=False, action_xmlid=False, context=None):
2977 """
2978- Change first "Invoice" word from message into "Debit Note" if this invoice is a debit note.
2979- Change it to "In-kind donation" if this invoice is an In-kind donation.
2980+ Updates the log message with the right document name + link it to the right action_act_window
2981 """
2982- if not context:
2983+ if context is None:
2984 context = {}
2985- local_ctx = context.copy()
2986- # Prepare some values
2987- # Search donation view and return it
2988- try:
2989- # try / except for runbot
2990- debit_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_override', 'view_debit_note_form')
2991- inkind_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_override', 'view_inkind_donation_form')
2992- intermission_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_override', 'view_intermission_form')
2993- supplier_invoice_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'invoice_supplier_form')
2994- customer_invoice_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'invoice_form')
2995- supplier_direct_invoice_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'register_accounting', 'direct_supplier_invoice_form')
2996- except ValueError:
2997- return super(account_invoice, self).log(cr, uid, inv_id, message, secondary, action_xmlid, context)
2998- debit_view_id = debit_res and debit_res[1] or False
2999- debit_note_ctx = {'view_id': debit_view_id, 'type':'out_invoice', 'journal_type': 'sale', 'is_debit_note': True}
3000- # Search donation view and return it
3001- inkind_view_id = inkind_res and inkind_res[1] or False
3002- inkind_ctx = {'view_id': inkind_view_id, 'type':'in_invoice', 'journal_type': 'inkind', 'is_inkind_donation': True}
3003- # Search intermission view
3004- intermission_view_id = intermission_res and intermission_res[1] or False
3005- intermission_ctx = {'view_id': intermission_view_id, 'journal_type': 'intermission', 'is_intermission': True}
3006- customer_view_id = customer_invoice_res[1] or False
3007- customer_ctx = {'view_id': customer_view_id, 'type': 'out_invoice', 'journal_type': 'sale'}
3008- message_changed = False
3009+ # update the message
3010 pattern = re.compile('^(Invoice)')
3011- for el in [('is_debit_note', 'Debit Note', debit_note_ctx), ('is_inkind_donation', 'In-kind Donation', inkind_ctx), ('is_intermission', 'Intermission Voucher', intermission_ctx)]:
3012- if self.read(cr, uid, inv_id, [el[0]]).get(el[0], False) is True:
3013- m = re.match(pattern, message)
3014- if m and m.groups():
3015- message = re.sub(pattern, el[1], message, 1)
3016- message_changed = True
3017- local_ctx.update(el[2])
3018- # UF-1112: Give all customer invoices a name as "Stock Transfer Voucher".
3019- if not message_changed and self.read(cr, uid, inv_id, ['type']).get('type', False) == 'out_invoice':
3020- if local_ctx.get('is_intermission', False):
3021- message = re.sub(pattern, 'Intermission Voucher', message, 1)
3022- local_ctx.update(intermission_ctx)
3023- else:
3024- message = re.sub(pattern, 'Stock Transfer Voucher', message, 1)
3025- local_ctx.update(customer_ctx)
3026-
3027- # UF-1307: for supplier invoice log (from the incoming shipment), the context was not
3028- # filled with all the information; this leaded to having a "Sale" journal in the supplier
3029- # invoice if it was saved after coming from this link. Here's the fix.
3030- if local_ctx.get('type', False) == 'in_invoice':
3031- if not local_ctx.get('journal_type', False):
3032- supplier_view_id = supplier_invoice_res and supplier_invoice_res[1] or False
3033- local_ctx.update({'journal_type': 'purchase',
3034- 'view_id': supplier_view_id})
3035- elif local_ctx.get('direct_invoice_view', False): # UFTP-166: The wrong context saved in log
3036- supplier_view_id = supplier_direct_invoice_res and supplier_direct_invoice_res[1] or False
3037- local_ctx = {'journal_type': 'purchase',
3038- 'view_id': supplier_view_id}
3039- return super(account_invoice, self).log(cr, uid, inv_id, message, secondary, action_xmlid, local_ctx)
3040+ doc_type = self.read(cr, uid, inv_id, ['doc_type'], context=context)['doc_type'] or ''
3041+ action_xmlid = self._invoice_action_act_window.get(doc_type) or action_xmlid
3042+ doc_name = dict(self.fields_get(cr, uid, context=context)['doc_type']['selection']).get(doc_type)
3043+ if doc_name:
3044+ m = re.match(pattern, message)
3045+ if m and m.groups():
3046+ message = re.sub(pattern, doc_name, message, 1)
3047+ return super(account_invoice, self).log(cr, uid, inv_id, message, secondary, action_xmlid=action_xmlid, context=context)
3048
3049 def _check_tax_allowed(self, cr, uid, ids, context=None):
3050 """
3051@@ -931,6 +971,12 @@
3052
3053 return True
3054
3055+ def invoice_open2(self, cr, uid, ids, context=None):
3056+ """
3057+ Alias for invoice_open (used to handle different characteristics on both buttons)
3058+ """
3059+ return self.invoice_open(cr, uid, ids, context=context)
3060+
3061 def invoice_open_with_confirmation(self, cr, uid, ids, context=None):
3062 """
3063 Simply calls "invoice_open" (asking for confirmation is done at form level)
3064@@ -996,7 +1042,7 @@
3065 def action_cancel(self, cr, uid, ids, *args):
3066 """
3067 Reverse move if this object is a In-kind Donation. Otherwise do normal job: cancellation.
3068- Don't delete an invoice that is linked to a PO. This is only for supplier invoices.
3069+ Don't cancel an invoice that is linked to a PO.
3070 """
3071 # Oct. 2019: log if this method is used at least once (cf it may be dead code?)
3072 self.pool.get('ir.config_parameter').set_param(cr, 1, 'action_cancel.in_use', True)
3073@@ -1041,43 +1087,6 @@
3074 self._check_document_date(cr, uid, ids)
3075 return res
3076
3077- def get_account_invoice_type(self, cr, uid, inv_id, context=None):
3078- """
3079- Returns the type of the account.invoice document as a string
3080- It can be: 'si', 'sr', 'di', 'ivi', 'ivo', 'stv', 'dn', 'cr', 'donation'
3081- Raises an error if the type is not recognized.
3082- """
3083- if context is None:
3084- context = {}
3085- inv_type = False
3086- fields = ['type', 'is_debit_note', 'is_inkind_donation', 'is_intermission', 'is_direct_invoice', 'internal_number']
3087- inv = self.browse(cr, uid, inv_id, fields_to_fetch=fields, context=context)
3088- if inv.is_debit_note:
3089- if inv.type == 'out_invoice':
3090- inv_type = 'dn' # Debit Note
3091- elif inv.is_inkind_donation:
3092- if inv.type == 'in_invoice':
3093- inv_type = 'donation'
3094- elif inv.is_intermission:
3095- if inv.type == 'in_invoice':
3096- inv_type = 'ivi' # Intermission Voucher In
3097- elif inv.type == 'out_invoice':
3098- inv_type = 'ivo' # Intermission Voucher Out
3099- elif inv.type == 'in_invoice':
3100- if inv.is_direct_invoice:
3101- inv_type = 'di' # Direct Invoice
3102- else:
3103- inv_type = 'si' # Supplier Invoice
3104- elif inv.type == 'in_refund':
3105- inv_type = 'sr' # Supplier Refund
3106- elif inv.type == 'out_invoice':
3107- inv_type = 'stv' # Stock Transfer Voucher'
3108- elif inv.type == 'out_refund':
3109- inv_type = 'cr' # Customer Refund'
3110- if not inv_type:
3111- raise osv.except_osv(_('Error'), _('The type of the document %s is unknown.') % inv.internal_number or '')
3112- return inv_type
3113-
3114 def _check_journal(self, cr, uid, inv_id, inv_type=None, context=None):
3115 """
3116 Raises an error if the type of the account.invoice and the journal used are not compatible
3117@@ -1087,10 +1096,11 @@
3118 journal = self.browse(cr, uid, inv_id, fields_to_fetch=['journal_id'], context=context).journal_id
3119 j_type = journal.type
3120 if inv_type is None:
3121- inv_type = self.get_account_invoice_type(cr, uid, inv_id, context=context)
3122- if inv_type in ('si', 'di') and j_type != 'purchase' or inv_type == 'sr' and j_type != 'purchase_refund' or \
3123- inv_type in ('ivi', 'ivo') and j_type != 'intermission' or inv_type in ('stv', 'dn') and j_type != 'sale' or \
3124- inv_type == 'cr' and j_type != 'sale_refund' or inv_type == 'donation' and j_type not in ('inkind', 'extra'):
3125+ inv_type = self.read(cr, uid, inv_id, ['doc_type'])['doc_type']
3126+ if inv_type in ('si', 'di', 'isi', 'isr') and j_type != 'purchase' or inv_type == 'sr' and j_type != 'purchase_refund' or \
3127+ inv_type in ('ivi', 'ivo') and j_type != 'intermission' or inv_type in ('stv', 'str', 'dn') and j_type != 'sale' or \
3128+ inv_type == 'cr' and j_type != 'sale_refund' or inv_type == 'donation' and j_type not in ('inkind', 'extra') or \
3129+ inv_type in ('isi', 'isr') and journal.code != 'ISI' or inv_type not in ('isi', 'isr') and journal.code == 'ISI':
3130 raise osv.except_osv(_('Error'), _("The journal %s is not allowed for this document.") % journal.name)
3131
3132 def _check_partner(self, cr, uid, inv_id, inv_type=None, context=None):
3133@@ -1102,13 +1112,15 @@
3134 partner = self.browse(cr, uid, inv_id, fields_to_fetch=['partner_id'], context=context).partner_id
3135 p_type = partner.partner_type
3136 if inv_type is None:
3137- inv_type = self.get_account_invoice_type(cr, uid, inv_id, context=context)
3138+ inv_type = self.read(cr, uid, inv_id, ['doc_type'])['doc_type']
3139 # if a supplier/customer is expected for the doc: check that the partner used has the right flag
3140- supplier_ko = inv_type in ('si', 'di', 'sr', 'ivi', 'donation') and not partner.supplier
3141- customer_ko = inv_type in ('ivo', 'stv', 'dn', 'cr') and not partner.customer
3142+ # note: SI/SR on Intersection partners are blocked only at form level (the validation of old docs should still be possible)
3143+ supplier_ko = inv_type in ('si', 'di', 'sr', 'ivi', 'donation', 'isi', 'isr') and not partner.supplier
3144+ customer_ko = inv_type in ('ivo', 'stv', 'dn', 'cr', 'str') and not partner.customer
3145 if supplier_ko or customer_ko or inv_type in ('ivi', 'ivo') and p_type != 'intermission' or \
3146- inv_type == 'stv' and p_type not in ('section', 'external') or \
3147- inv_type == 'donation' and p_type not in ('esc', 'external', 'section'):
3148+ inv_type in ('stv', 'str') and p_type not in ('section', 'external') or \
3149+ inv_type == 'donation' and p_type not in ('esc', 'external', 'section') or \
3150+ inv_type in ('isi', 'isr') and p_type != 'section':
3151 raise osv.except_osv(_('Error'), _("The partner %s is not allowed for this document.") % partner.name)
3152
3153 def _check_header_account(self, cr, uid, inv_id, inv_type=None, context=None):
3154@@ -1120,11 +1132,11 @@
3155 account_obj = self.pool.get('account.account')
3156 account = self.browse(cr, uid, inv_id, fields_to_fetch=['account_id'], context=context).account_id
3157 if inv_type is None:
3158- inv_type = self.get_account_invoice_type(cr, uid, inv_id, context=context)
3159+ inv_type = self.read(cr, uid, inv_id, ['doc_type'])['doc_type']
3160 account_domain = []
3161- if inv_type in ('si', 'di', 'sr'):
3162+ if inv_type in ('si', 'di', 'sr', 'isi', 'isr'):
3163 account_domain.append(('restricted_area', '=', 'in_invoice'))
3164- elif inv_type in ('stv', 'cr'):
3165+ elif inv_type in ('stv', 'cr', 'str'):
3166 account_domain.append(('restricted_area', '=', 'out_invoice'))
3167 elif inv_type == 'dn':
3168 account_domain.append(('restricted_area', '=', 'out_invoice'))
3169@@ -1152,9 +1164,9 @@
3170 inv_line_obj = self.pool.get('account.invoice.line')
3171 lines = inv_line_obj.search(cr, uid, [('invoice_id', '=', inv_id)], context=context, order='NO_ORDER')
3172 if inv_type is None:
3173- inv_type = self.get_account_invoice_type(cr, uid, inv_id, context=context)
3174+ inv_type = self.read(cr, uid, inv_id, ['doc_type'])['doc_type']
3175 account_domain = []
3176- if inv_type in ('si', 'di', 'sr', 'cr'):
3177+ if inv_type in ('si', 'di', 'sr', 'cr', 'isi', 'isr', 'str'):
3178 account_domain.append(('restricted_area', '=', 'invoice_lines'))
3179 elif inv_type == 'stv':
3180 context.update(({'check_line_stv': True, }))
3181@@ -1175,7 +1187,7 @@
3182 if context is None:
3183 context = {}
3184 for inv_id in ids:
3185- inv_type = self.get_account_invoice_type(cr, uid, inv_id, context=context)
3186+ inv_type = self.read(cr, uid, inv_id, ['doc_type'])['doc_type']
3187 self._check_journal(cr, uid, inv_id, inv_type=inv_type, context=context)
3188 self._check_partner(cr, uid, inv_id, inv_type=inv_type, context=context)
3189 self._check_header_account(cr, uid, inv_id, inv_type=inv_type, context=context)
3190@@ -1298,6 +1310,12 @@
3191 }
3192 return False
3193
3194+ def button_split_invoice2(self, cr, uid, ids, context=None):
3195+ """
3196+ Alias for button_split_invoice (used to handle different characteristics on both buttons)
3197+ """
3198+ return self.button_split_invoice(cr, uid, ids, context=context)
3199+
3200 def button_donation_certificate(self, cr, uid, ids, context=None):
3201 """
3202 Open a view containing a list of all donation certificates linked to the given invoice.
3203@@ -1578,6 +1596,12 @@
3204
3205 return res
3206
3207+ def button_merge_lines2(self, cr, uid, ids, context=None):
3208+ """
3209+ Alias for button_merge_lines (used to handle different characteristics on both buttons)
3210+ """
3211+ return self.button_merge_lines(cr, uid, ids, context=context)
3212+
3213 def check_accounts_for_partner(self, cr, uid, ids, context=None,
3214 header_obj=False, lines_field='invoice_line',
3215 line_level_partner_type=False):
3216@@ -1766,6 +1790,12 @@
3217 res[i] = False
3218 return res
3219
3220+ def _get_line_doc_type(self, cr, uid, context=None):
3221+ """
3222+ Gets the list of possible invoice types
3223+ """
3224+ return self.pool.get('account.invoice')._get_invoice_type_list(cr, uid, context=context)
3225+
3226 _columns = {
3227 'line_number': fields.integer(string='Line Number'),
3228 'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Account Computation')),
3229@@ -1798,6 +1828,8 @@
3230 # (avoids having 2 fields with the same name within the same view)
3231 'line_synced': fields.related('invoice_id', 'synced', type='boolean', string='Synchronized', readonly=True, store=False,
3232 help='Technical field, similar to "synced"'),
3233+ 'line_doc_type': fields.related('invoice_id', 'doc_type', type='selection', selection=_get_line_doc_type,
3234+ string='Document Type', store=False),
3235 'invoice_type': fields.related('invoice_id', 'type', string='Invoice Type', type='selection', readonly=True, store=False,
3236 selection=[('out_invoice', 'Customer Invoice'),
3237 ('in_invoice', 'Supplier Invoice'),
3238@@ -1856,14 +1888,14 @@
3239 inv_fields = ['from_supply', 'synced', 'type', 'is_inkind_donation', 'partner_type']
3240 inv = inv_obj.browse(cr, uid, invoice_id, fields_to_fetch=inv_fields, context=context)
3241 if not inv.is_inkind_donation: # never block manual line creation in Donations whatever the workflow and partner type
3242- ivi_or_si_synced = inv.type == 'in_invoice' and inv.synced
3243+ ivi_or_isi_synced = inv.type == 'in_invoice' and inv.synced
3244 intermission_or_section_from_supply = inv.partner_type in ('intermission', 'section') and inv.from_supply
3245 from_split = context.get('from_split')
3246 if context.get('from_inv_form'):
3247- if from_split and ivi_or_si_synced:
3248+ if from_split and ivi_or_isi_synced:
3249 raise osv.except_osv(_('Error'), _('This document has been generated via synchronization. '
3250 'You can\'t split its lines.'))
3251- elif not from_split and (ivi_or_si_synced or intermission_or_section_from_supply):
3252+ elif not from_split and (ivi_or_isi_synced or intermission_or_section_from_supply):
3253 raise osv.except_osv(_('Error'), _('This document has been generated via a Supply workflow or via synchronization. '
3254 'You can\'t add lines manually.'))
3255
3256
3257=== modified file 'bin/addons/account_override/report/account_print_invoice.rml'
3258--- bin/addons/account_override/report/account_print_invoice.rml 2021-04-26 10:34:04 +0000
3259+++ bin/addons/account_override/report/account_print_invoice.rml 2021-11-03 13:33:55 +0000
3260@@ -227,9 +227,10 @@
3261 [[ ((o.type == 'out_invoice' and o.state == 'draft') or removeParentNode('para')) and '' ]]</para>
3262 <para style="terp_header">[[ o.is_debit_note and translate('Cancelled Debit Note') or o.is_intermission and translate('Cancelled Intermission Voucher OUT') or o.is_inkind_donation and translate('Cancelled In-kind Donation') or translate('Cancelled Invoice') ]] [[ o.number or '' ]]
3263 [[ (((o.type == 'out_invoice' or o.is_inkind_donation) and o.state == 'cancel') or removeParentNode('para')) and '' ]]</para>
3264- <para style="terp_header">Refund [[ (o.type=='out_refund' or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
3265- <para style="terp_header">Supplier Refund [[ (o.type=='in_refund' or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
3266- <para style="terp_header">[[ o.is_inkind_donation == True and translate('In-kind Donation') or o.is_intermission and translate('Intermission Voucher IN') or ( o.type == 'in_invoice' and not o.register_line_ids ) and translate('Supplier Invoice') or translate('Supplier Direct Invoice') ]] [[ o.number ]]
3267+ <para style="terp_header">Refund [[ (o.doc_type in ('cr', 'str') or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
3268+ <para style="terp_header">Supplier Refund [[ (o.doc_type == 'sr' or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
3269+ <para style="terp_header">Intersection Supplier Refund [[ (o.doc_type == 'isr' or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
3270+ <para style="terp_header">[[ o.doc_type == 'donation' and translate('In-kind Donation') or o.doc_type == 'ivi' and translate('Intermission Voucher IN') or o.doc_type == 'si' and translate('Supplier Invoice') or o.doc_type == 'isi' and translate('Intersection Supplier Invoice') or translate('Supplier Direct Invoice') ]] [[ o.number ]]
3271 [[ (o.type == 'in_invoice' and (not o.is_inkind_donation or o.state != 'cancel') or removeParentNode('para')) and '' ]]</para>
3272 <para style="terp_default_8">
3273 <font color="white"> </font>
3274
3275=== modified file 'bin/addons/account_override/report/open_invoices_xls.mako'
3276--- bin/addons/account_override/report/open_invoices_xls.mako 2017-08-04 15:15:29 +0000
3277+++ bin/addons/account_override/report/open_invoices_xls.mako 2021-11-03 13:33:55 +0000
3278@@ -302,10 +302,12 @@
3279 <Row><Cell><Data ss:Type="String"></Data></Cell></Row>
3280
3281 <% inv = invoices(data) %>
3282-<% doc_type_list = [('si_di', _('Supplier Invoices')), ('sr', _('Supplier Refunds')), ('donation', _('Donations')),
3283- ('ivi', _('Intermission Vouchers IN')), ('stv', _('Stock Transfer Vouchers')), ('cr', _('Customer Refunds')),
3284+<% doc_type_list = [('si_di', _('Supplier Invoices')), ('sr', _('Supplier Refunds')),
3285+ ('isi', _('Intersection Supplier Invoices')), ('isr', _('Intersection Supplier Refunds')),
3286+ ('donation', _('Donations')), ('ivi', _('Intermission Vouchers IN')),
3287+ ('stv', _('Stock Transfer Vouchers')), ('str', _('Stock Transfer Refunds')), ('cr', _('Customer Refunds')),
3288 ('dn', _('Debit Notes')), ('ivo', _('Intermission Vouchers OUT'))] %>
3289-% for (type, title) in doc_type_list:
3290+% for (doc_type, title) in doc_type_list:
3291 <Row >
3292 <Cell ss:StyleID="s23"><Data ss:Type="String">${title}</Data></Cell>
3293 <Cell ss:StyleID="s24"/>
3294@@ -329,9 +331,9 @@
3295 <Cell ss:StyleID="s27"><Data ss:Type="String">${_('Number')}</Data></Cell>
3296 <Cell ss:StyleID="s27"><Data ss:Type="String">${_('Document Date')}</Data></Cell>
3297 <Cell ss:StyleID="s27"><Data ss:Type="String">${_('Posting Date')}</Data></Cell>
3298-% if type in ['stv', 'ivo', 'dn', 'cr']:
3299+% if doc_type in ['stv', 'ivo', 'dn', 'cr', 'str']:
3300 <Cell ss:StyleID="s27"><Data ss:Type="String">${_('Customer')}</Data></Cell>
3301-% elif type in ['si_di', 'ivi', 'donation', 'sr']:
3302+% elif doc_type in ['si_di', 'ivi', 'donation', 'sr', 'isi', 'isr']:
3303 <Cell ss:StyleID="s27"><Data ss:Type="String">${_('Supplier')}</Data></Cell>
3304 % else:
3305 <Cell ss:StyleID="s27"><Data ss:Type="String">${_('Partner')}</Data></Cell>
3306@@ -357,8 +359,8 @@
3307
3308 <% nb_line = 0 %>
3309
3310-% if type in inv:
3311-% for o in inv[type]:
3312+% if doc_type in inv:
3313+% for o in inv[doc_type]:
3314 <Row>
3315 <% nb_line += 1 %>
3316 <% update_percent(nb_line, context) %>
3317
3318=== modified file 'bin/addons/account_override/report/report_open_invoices.py'
3319--- bin/addons/account_override/report/report_open_invoices.py 2019-07-25 14:01:42 +0000
3320+++ bin/addons/account_override/report/report_open_invoices.py 2021-11-03 13:33:55 +0000
3321@@ -72,48 +72,20 @@
3322 self.percent = 0.05 # 5% of the process
3323 bg_obj.update_percent(self.cr, self.uid, [bg_id], self.percent)
3324 states = context.get('paid_invoice') and ['paid', 'inv_close'] or ['open']
3325- for type in ['si_di', 'sr', 'donation', 'ivi', 'stv', 'cr', 'dn', 'ivo']:
3326+ for doc_type in ['si_di', 'sr', 'isi', 'isr', 'donation', 'ivi', 'stv', 'str', 'cr', 'dn', 'ivo']:
3327 # determine the domain to use according to the report type and the doc type
3328 domain = [('state', 'in', states)]
3329 if context.get('paid_invoice') and beginning_date and ending_date:
3330 domain += [('date_invoice', '>=', beginning_date), ('date_invoice', '<=', ending_date)]
3331- if type == 'si_di':
3332- domain += [('type', '=', 'in_invoice'),
3333- ('is_inkind_donation', '=', False),
3334- ('is_debit_note', '=', False),
3335- ('is_intermission', '=', False)]
3336- elif type == 'sr':
3337- domain += [('type', '=', 'in_refund')]
3338- elif type == 'donation':
3339- domain += [('type', '=', 'in_invoice'),
3340- ('is_debit_note', '=', False),
3341- ('is_inkind_donation', '=', True)]
3342- elif type == 'ivi':
3343- domain += [('type', '=', 'in_invoice'),
3344- ('is_debit_note', '=', False),
3345- ('is_inkind_donation', '=', False),
3346- ('is_intermission', '=', True)]
3347- elif type == 'stv':
3348- domain += [('type', '=', 'out_invoice'),
3349- ('is_debit_note', '=', False),
3350- ('is_inkind_donation', '=', False),
3351- ('is_intermission', '=', False)]
3352- elif type == 'cr':
3353- domain += [('type', '=', 'out_refund')]
3354- elif type == 'dn':
3355- domain += [('type', '=', 'out_invoice'),
3356- ('is_debit_note', '!=', False),
3357- ('is_inkind_donation', '=', False)]
3358- elif type == 'ivo':
3359- domain += [('type','=','out_invoice'),
3360- ('is_debit_note', '=', False),
3361- ('is_inkind_donation', '=', False),
3362- ('is_intermission', '=', True)]
3363+ if doc_type == 'si_di':
3364+ domain += [('doc_type', 'in', ['si', 'di'])]
3365+ elif doc_type in ('sr', 'isi', 'isr', 'donation', 'ivi', 'stv', 'str', 'cr', 'dn', 'ivo'):
3366+ domain += [('doc_type', '=', doc_type)]
3367 type_ids = inv_obj.search(self.cr, self.uid, domain, context=context, order='move_name')
3368 if isinstance(type_ids, (int, long)):
3369 type_ids = [type_ids]
3370 self.nb_lines += len(type_ids)
3371- res.update({type: inv_obj.browse(self.cr, self.uid, type_ids, context)})
3372+ res.update({doc_type: inv_obj.browse(self.cr, self.uid, type_ids, context)})
3373 if bg_id:
3374 self.percent += 0.20 # 25% of the process
3375 bg_obj.update_percent(self.cr, self.uid, [bg_id], self.percent)
3376
3377=== modified file 'bin/addons/account_payment/__openerp__.py'
3378--- bin/addons/account_payment/__openerp__.py 2019-10-10 15:06:49 +0000
3379+++ bin/addons/account_payment/__openerp__.py 2021-11-03 13:33:55 +0000
3380@@ -33,7 +33,6 @@
3381 'author': 'OpenERP SA',
3382 'depends': ['account'],
3383 'update_xml': [
3384- 'account_invoice_view.xml',
3385 ],
3386 'demo_xml': [],
3387 'test': [
3388
3389=== removed file 'bin/addons/account_payment/account_invoice_view.xml'
3390=== modified file 'bin/addons/account_period_closing_level/account_period.py'
3391--- bin/addons/account_period_closing_level/account_period.py 2021-08-25 14:50:30 +0000
3392+++ bin/addons/account_period_closing_level/account_period.py 2021-11-03 13:33:55 +0000
3393@@ -501,7 +501,7 @@
3394 context = {}
3395 return self.register_view(cr, uid, ids, 'cash', context=context)
3396
3397- def invoice_view(self, cr, uid, ids, action_xmlid=None, context=None):
3398+ def invoice_view(self, cr, uid, ids, action_xmlid=None, doc_type=None, context=None):
3399 """
3400 Open an invoice tree view with the given domain for the period in ids
3401 """
3402@@ -510,17 +510,11 @@
3403 context = {}
3404 if isinstance(ids, (int, long)):
3405 ids = [ids]
3406-
3407- # to get action_xmlid:
3408- # 1/ on the web interface get id of ir.ui.menu menu
3409- # 2/ get id of ir.actions.act_window:
3410- # select value from ir_values where model='ir.ui.menu' and res_id=<menu_id>;
3411- # 3/ get xmlid:
3412- # select module||'.'||name from ir_model_data where res_id=<act_id> and module!='sd' and model='ir.actions.act_window';
3413- module, xmlid = action_xmlid.split('.', 1)
3414- act_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, module, xmlid)[1]
3415- keys = ['display_menu_tip', 'help', 'type', 'domain', 'res_model', 'view_id', 'search_view_id', 'view_mode', 'view_ids', 'context', 'name', 'views', 'view_type']
3416- act = self.pool.get('ir.actions.act_window').read(cr, uid, act_id, keys, context=context)
3417+ if not action_xmlid and doc_type:
3418+ action_xmlid = self.pool.get('account.invoice')._invoice_action_act_window.get(doc_type)
3419+ if not action_xmlid:
3420+ raise osv.except_osv(_('Warning'), _('Impossible to retrieve the view to display.'))
3421+ act = self.pool.get('ir.actions.act_window').open_view_from_xmlid(cr, uid, action_xmlid, context=context)
3422 act_domain = act.get('domain', "[]") or "[]"
3423 act_context = act.get('context', "{}") or "{}"
3424 globals_dict = {'uid': uid}
3425@@ -535,7 +529,22 @@
3426 eval_domain += [('date_invoice', '<=', period['date_stop']), ('state', 'in', ['draft', 'open'])]
3427
3428 eval_context = safe_eval(act_context, globals_dict)
3429- eval_context['search_default_draft'] = 0
3430+
3431+ model_name = hasattr(model_obj, '_name') and getattr(model_obj, '_name')
3432+ model_inherit_name = hasattr(model_obj, '_inherit') and getattr(model_obj, '_inherit')
3433+ if model_name == 'account.invoice' or model_inherit_name == 'account.invoice':
3434+ # activate the Draft and Open filters
3435+ eval_context['search_default_draft'] = 1
3436+ if eval_context.get('doc_type') == 'donation':
3437+ eval_context['search_default_open'] = 1
3438+ eval_context['search_cancel_state_donation'] = 0
3439+ else:
3440+ eval_context['search_default_unpaid'] = 1 # Open
3441+ eval_context['search_default_paid'] = 0
3442+ eval_context['search_default_closed'] = 0
3443+ if eval_context.get('doc_type') in ('ivo', 'stv'):
3444+ eval_context['search_default_cancel_state'] = 0
3445+
3446 act['context'] = eval_context
3447 act['domain'] = eval_domain
3448 act['target'] = 'current'
3449@@ -546,68 +555,76 @@
3450 """
3451 Create a new tab with Open stock transfer vouchers from given period.
3452 """
3453- return self.invoice_view(cr, uid, ids, action_xmlid='account.action_invoice_tree1', context=context)
3454+ return self.invoice_view(cr, uid, ids, doc_type='stv', context=context)
3455
3456 def button_customer_refunds(self, cr, uid, ids, context=None):
3457 """
3458 Create a new tab with Customer refunds from given period.
3459 """
3460- return self.invoice_view(cr, uid, ids, action_xmlid='account.action_invoice_tree3', context=context)
3461+ return self.invoice_view(cr, uid, ids, doc_type='cr', context=context)
3462
3463 # Debit note
3464 def button_debit_note(self, cr, uid, ids, context=None):
3465- return self.invoice_view(cr, uid, ids,
3466- action_xmlid='account_override.action_debit_note',
3467- context=context)
3468+ return self.invoice_view(cr, uid, ids, doc_type='dn', context=context)
3469
3470 # Intermission voucher OUT
3471 def button_intermission_out(self, cr, uid, ids, context=None):
3472- return self.invoice_view(cr, uid, ids,
3473- action_xmlid='account_override.action_intermission_out',
3474- context=context)
3475+ return self.invoice_view(cr, uid, ids, doc_type='ivo', context=context)
3476
3477 def button_supplier_refunds(self, cr, uid, ids, context=None):
3478 """
3479- Open a view that display Supplier invoices for given period
3480+ Open a view that displays Supplier Refunds for given period
3481 """
3482- return self.invoice_view(cr, uid, ids,
3483- action_xmlid='account.action_invoice_tree4', context=context)
3484+ return self.invoice_view(cr, uid, ids, doc_type='sr', context=context)
3485
3486 # Supplier direct invoices
3487 def button_supplier_direct_invoices(self, cr, uid, ids, context=None):
3488 """
3489 Open a view that display Direct invoices for this period
3490 """
3491- return self.invoice_view(cr, uid, ids,
3492- action_xmlid='register_accounting.action_direct_invoice',
3493- context=context)
3494+ return self.invoice_view(cr, uid, ids, doc_type='di', context=context)
3495
3496 # In-kind donation
3497 def button_donation(self, cr, uid, ids, context=None):
3498 """
3499 Open a view that display Inkind donation for this period
3500 """
3501- return self.invoice_view(cr, uid, ids,
3502- action_xmlid='account_override.action_inkind_donation',
3503- context=context)
3504+ return self.invoice_view(cr, uid, ids, doc_type='donation', context=context)
3505
3506 # Intermission voucher IN
3507 def button_intermission_in(self, cr, uid, ids, context=None):
3508 """
3509 Open a view that display intermission voucher in for this period
3510 """
3511- return self.invoice_view(cr, uid, ids,
3512- action_xmlid='account_override.action_intermission_in',
3513- context=context)
3514+ return self.invoice_view(cr, uid, ids, doc_type='ivi', context=context)
3515
3516 # Supplier invoice
3517 def button_supplier_invoices(self, cr, uid, ids, context=None):
3518 """
3519 Open a view that display supplier invoices for this period
3520 """
3521- return self.invoice_view(cr, uid, ids,
3522- action_xmlid='account.action_invoice_tree2',
3523- context=context)
3524+ return self.invoice_view(cr, uid, ids, doc_type='si', context=context)
3525+
3526+ # Intersection Supplier Invoice
3527+ def button_intersection_supplier_invoices(self, cr, uid, ids, context=None):
3528+ """
3529+ Opens a view with the ISI to check before closing the period
3530+ """
3531+ return self.invoice_view(cr, uid, ids, doc_type='isi', context=context)
3532+
3533+ # Intersection Supplier Refund
3534+ def button_intersection_supplier_refunds(self, cr, uid, ids, context=None):
3535+ """
3536+ Opens a view with the ISR to check before closing the period
3537+ """
3538+ return self.invoice_view(cr, uid, ids, doc_type='isr', context=context)
3539+
3540+ # Stock Transfer Refund
3541+ def button_stock_transfer_refunds(self, cr, uid, ids, context=None):
3542+ """
3543+ Opens a view with the STR to check before closing the period
3544+ """
3545+ return self.invoice_view(cr, uid, ids, doc_type='str', context=context)
3546
3547 def button_close_field_period(self, cr, uid, ids, context=None):
3548 if not context:
3549
3550=== modified file 'bin/addons/account_period_closing_level/account_period_closing_level_view.xml'
3551--- bin/addons/account_period_closing_level/account_period_closing_level_view.xml 2019-10-29 14:39:06 +0000
3552+++ bin/addons/account_period_closing_level/account_period_closing_level_view.xml 2021-11-03 13:33:55 +0000
3553@@ -152,15 +152,18 @@
3554 <label string="Did you check draft and open customer documents?" colspan="6" align="0.0"/>
3555 <group colspan="6" col="6">
3556 <button string="Stock transfer vouchers" name="button_stock_transfer_vouchers" type="object" icon="gtk-dnd" colspan="2"/>
3557+ <button string="Stock Transfer Refunds" name="button_stock_transfer_refunds" type="object" icon="gtk-dnd" colspan="2"/>
3558 <button string="Customer Refunds" name="button_customer_refunds" type="object" icon="gtk-dnd" colspan="2"/>
3559+ <button string="Intermission Voucher OUT" name="button_intermission_out" type="object" icon="gtk-dnd" colspan="2"/>
3560 <button string="Debit Note" name="button_debit_note" type="object" icon="gtk-dnd" colspan="2"/>
3561- <button string="Intermission Voucher OUT" name="button_intermission_out" type="object" icon="gtk-dnd" colspan="2"/>
3562 </group>
3563 <label string="Did you check draft and open supplier documents?" colspan="6" align="0.0"/>
3564 <group colspan="6" col="6">
3565 <button string="Supplier invoices" name="button_supplier_invoices" type="object" icon="gtk-dnd" colspan="2"/>
3566 <button string="Supplier refunds" name="button_supplier_refunds" type="object" icon="gtk-dnd" colspan="2"/>
3567 <button string="Supplier direct invoices" name="button_supplier_direct_invoices" type="object" icon="gtk-dnd" colspan="2"/>
3568+ <button string="Intersection Supplier Invoices" name="button_intersection_supplier_invoices" type="object" icon="gtk-dnd" colspan="2"/>
3569+ <button string="Intersection Supplier Refunds" name="button_intersection_supplier_refunds" type="object" icon="gtk-dnd" colspan="2"/>
3570 <button string="Donation" name="button_donation" type="object" icon="gtk-dnd" colspan="2"/>
3571 <button string="Intermission Voucher IN" name="button_intermission_in" type="object" icon="gtk-dnd" colspan="2"/>
3572 </group>
3573
3574=== modified file 'bin/addons/account_period_closing_level/account_year_end_closing.xml'
3575--- bin/addons/account_period_closing_level/account_year_end_closing.xml 2016-11-04 12:57:37 +0000
3576+++ bin/addons/account_period_closing_level/account_year_end_closing.xml 2021-11-03 13:33:55 +0000
3577@@ -2,21 +2,6 @@
3578 <openerp>
3579 <data>
3580
3581- <record id="view_account_form_inherit" model="ir.ui.view">
3582- <field name="name">account.account.form</field>
3583- <field name="model">account.account</field>
3584- <field name="type">form</field>
3585- <field name="priority">55</field>
3586- <field name="inherit_id" ref="account.view_account_form"/>
3587- <field name="arch" type="xml">
3588- <xpath expr="//notebook" position="inside">
3589- <page string="End Year Closing" attrs="{'invisible': [('instance_level', '=', 'project')]}">
3590- <field name="include_in_yearly_move"
3591- attrs="{'readonly': ['|', ('instance_level', '!=', 'section'), ('type', 'not in', ['other', ])]}"/>
3592- </page>
3593- </xpath>
3594- </field>
3595- </record>
3596
3597 <record id="account.action_account_fiscalyear_form" model="ir.actions.act_window">
3598 <field name="name">Fiscal Years</field>
3599@@ -37,4 +22,4 @@
3600 </record>
3601
3602 </data>
3603-</openerp>
3604\ No newline at end of file
3605+</openerp>
3606
3607=== modified file 'bin/addons/account_subscription/account_model_view.xml'
3608--- bin/addons/account_subscription/account_model_view.xml 2020-08-17 16:32:14 +0000
3609+++ bin/addons/account_subscription/account_model_view.xml 2021-11-03 13:33:55 +0000
3610@@ -26,7 +26,7 @@
3611 <group col="6" colspan="4">
3612 <group attrs="{'readonly': [('state', '=', 'done')]}" colspan="6" col="6">
3613 <field name="name"/>
3614- <field name="journal_id" domain="[('type', '=', 'purchase'), ('is_current_instance', '=', True)]"/>
3615+ <field name="journal_id" domain="[('type', '=', 'purchase'), ('code', '!=', 'ISI'), ('is_current_instance', '=', True)]"/>
3616 <field name="currency_id"/>
3617 </group>
3618 <group colspan="6" col="6" attrs="{'invisible': [('analytic_distribution_id', '=', False)]}">
3619
3620=== modified file 'bin/addons/analytic_distribution/account_commitment.py'
3621--- bin/addons/analytic_distribution/account_commitment.py 2021-08-17 13:24:42 +0000
3622+++ bin/addons/analytic_distribution/account_commitment.py 2021-11-03 13:33:55 +0000
3623@@ -29,7 +29,7 @@
3624 import decimal_precision as dp
3625 from account_override.period import get_period_from_date
3626 from tools.misc import flatten
3627-
3628+import netsvc
3629
3630 class account_commitment(osv.osv):
3631 _name = 'account.commitment'
3632@@ -48,11 +48,23 @@
3633 ids = [ids]
3634 # Prepare some values
3635 res = {}
3636+ for _id in ids:
3637+ res[_id] = 0
3638 # Browse commitments
3639- for co in self.browse(cr, uid, ids, context=context):
3640- res[co.id] = 0.0
3641- for line in co.line_ids:
3642- res[co.id] += line.amount
3643+ if ids:
3644+ cr.execute('''
3645+ select
3646+ commit_id, sum(amount)
3647+ from
3648+ account_commitment_line
3649+ where
3650+ commit_id in %s
3651+ group by
3652+ commit_id
3653+ ''', (tuple(ids),))
3654+ for x in cr.fetchall():
3655+ res[x[0]] = round(x[1], 2)
3656+
3657 return res
3658
3659 def _get_cv(self, cr, uid, ids, context=None):
3660@@ -86,8 +98,9 @@
3661
3662 def _display_super_done_button(self, cr, uid, ids, name, arg, context=None):
3663 """
3664- For now the "Super" Done button, which allows to always set a CV to Done whatever its state and origin,
3665- is visible only by the Admin user. It is displayed only when the standard Done button isn't usable.
3666+ The "Super" Done button, which allows to always set a CV to Done whatever its state and origin, is displayed:
3667+ - when the standard Done button isn't usable.
3668+ - only for some "admin" users (the restriction is made by User Rights).
3669 """
3670 if context is None:
3671 context = {}
3672@@ -96,14 +109,14 @@
3673 res = {}
3674 for cv in self.read(cr, uid, ids, ['state', 'type'], context=context):
3675 other_done_button_usable = cv['state'] == 'open' and cv['type'] not in ('external', 'intermission', 'intersection')
3676- res[cv['id']] = not other_done_button_usable and uid == 1 and cv['state'] != 'done'
3677+ res[cv['id']] = not other_done_button_usable and cv['state'] != 'done'
3678 return res
3679
3680 _columns = {
3681 'journal_id': fields.many2one('account.analytic.journal', string="Journal", readonly=True, required=True),
3682 'name': fields.char(string="Number", size=64, readonly=True, required=True),
3683 'currency_id': fields.many2one('res.currency', string="Currency", required=True),
3684- 'partner_id': fields.many2one('res.partner', string="Supplier", required=True),
3685+ 'partner_id': fields.many2one('res.partner', string="Partner", required=True),
3686 'period_id': fields.many2one('account.period', string="Period", readonly=True, required=True),
3687 'state': fields.selection([('draft', 'Draft'), ('open', 'Validated'), ('done', 'Done')], readonly=True, string="State", required=True),
3688 'date': fields.date(string="Commitment Date", readonly=True, required=True, states={'draft': [('readonly', False)], 'open': [('readonly', False)]}),
3689@@ -115,7 +128,9 @@
3690 'analytic_distribution_id': fields.many2one('analytic.distribution', string="Analytic distribution"),
3691 'type': fields.selection(get_cv_type, string="Type", readonly=True),
3692 'notes': fields.text(string="Comment"),
3693+ 'cv_flow_type': fields.selection([('customer', 'Customer'), ('supplier', 'Supplier')], string="Type of CV"),
3694 'purchase_id': fields.many2one('purchase.order', string="Source document", readonly=True),
3695+ 'sale_id': fields.many2one('sale.order', string="Source document", readonly=True),
3696 'description': fields.char(string="Description", size=256),
3697 'version': fields.integer('Version', required=True,
3698 help="Technical field to distinguish old CVs from new ones which have a different behavior."),
3699@@ -155,6 +170,10 @@
3700 partner = self.pool.get('res.partner').browse(cr, uid, [partner_id])
3701 if partner and partner[0] and not partner[0].active:
3702 raise osv.except_osv(_('Warning'), _("Partner '%s' is not active.") % (partner[0] and partner[0].name or '',))
3703+ if vals.get('sale_id'):
3704+ vals['cv_flow_type'] = 'customer'
3705+ elif vals.get('purchase_id'):
3706+ vals['cv_flow_type'] = 'supplier'
3707 # Add sequence
3708 sequence_number = self.pool.get('ir.sequence').get(cr, uid, self._name)
3709 instance = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.instance_id
3710@@ -441,6 +460,9 @@
3711 ids = [ids]
3712 # Browse commitments
3713 for c in self.browse(cr, uid, ids, context=context):
3714+ sign = 1
3715+ if c.cv_flow_type == 'customer':
3716+ sign = -1
3717 for cl in c.line_ids:
3718 # Verify that analytic distribution is present
3719 if cl.analytic_distribution_state != 'valid':
3720@@ -456,10 +478,10 @@
3721 if not al_ids:
3722 # Create engagement journal lines
3723 self.pool.get('analytic.distribution').\
3724- create_account_analytic_lines(cr, uid, [distrib_id], c.description or c.name, c.date, cl.amount,
3725+ create_account_analytic_lines(cr, uid, [distrib_id], c.description or c.name, c.date, sign * cl.amount,
3726 c.journal_id and c.journal_id.id,
3727 c.currency_id and c.currency_id.id, c.date or False,
3728- (c.purchase_id and c.purchase_id.name) or c.name or False, c.date,
3729+ (c.purchase_id and c.purchase_id.name or c.sale_id and c.sale_id.name) or c.name or False, c.date,
3730 cl.account_id and cl.account_id.id or False, False, False, cl.id, context=context)
3731 return True
3732
3733@@ -500,12 +522,56 @@
3734 self.write(cr, uid, [c.id], {'state':'done'}, context=context)
3735 return True
3736
3737+ def test_and_close_cv_so(self, cr, uid, ids, invoice_ids=None, context=None):
3738+ """
3739+ set amout=0 on CV lines linked to closed, cancelled(-r) FO line (no more invoices expected)
3740+ and with no draft invoice
3741+
3742+
3743+ invoice_ids: list of draft invoices to ignore (state will be changed later in the code)
3744+ """
3745+
3746+ if invoice_ids is None:
3747+ invoice_ids = []
3748+
3749+ iv_ids = invoice_ids[:]
3750+ if not iv_ids:
3751+ iv_ids.append(0)
3752+
3753+ cv_line_obj = self.pool.get('account.commitment.line')
3754+ cr.execute('''
3755+ select
3756+ line.id, line.amount
3757+ from
3758+ account_commitment_line line
3759+ left join
3760+ sale_order_line sol on sol.id = line.so_line_id
3761+ left join
3762+ account_invoice_line inv_line on inv_line.sale_order_line_id = sol.id and inv_line.invoice_id not in %s
3763+ left join
3764+ account_invoice inv on inv_line.invoice_id = inv.id and inv.type = 'out_invoice' and inv.from_supply = 't'
3765+ where
3766+ sol.state in ('done', 'cancel', 'cancel_r') and
3767+ line.amount != 0 and
3768+ line.commit_id in %s
3769+ group by
3770+ line.id, line.amount
3771+ having (count(inv.state='draft' or NULL) = 0)
3772+ ''', (tuple(iv_ids), tuple(ids)))
3773+ # from_supply + out_invoice : to ignore draft refund
3774+
3775+ for x in cr.fetchall():
3776+ cv_line_obj._update_so_commitment_line(cr, uid, x[0], x[1], from_cancel=True, context=context)
3777+
3778+ return True
3779+
3780+
3781 account_commitment()
3782
3783 class account_commitment_line(osv.osv):
3784 _name = 'account.commitment.line'
3785 _description = "Account Commitment Voucher Line"
3786- _order = "po_line_id, id desc"
3787+ _order = "line_number, id desc"
3788 _rec_name = 'account_id'
3789 _trace = True
3790
3791@@ -574,10 +640,9 @@
3792 string="Purchase Order Lines (deprecated)", readonly=True),
3793 # for CV starting from version 2
3794 'po_line_id': fields.many2one('purchase.order.line', "PO Line"),
3795- 'po_line_product_id': fields.related('po_line_id', 'product_id', type='many2one', relation='product.product',
3796- string="Product", readonly=True, store=True, write_relate=False),
3797- 'po_line_number': fields.related('po_line_id', 'line_number', type='integer_null', string="PO Line", readonly=True,
3798- store=True, write_relate=False, _fnct_migrate=lambda *a: True),
3799+ 'so_line_id': fields.many2one('sale.order.line', "SO Line"),
3800+ 'line_product_id': fields.many2one('product.product', string="Product", readonly=True),
3801+ 'line_number': fields.integer_null('Line', readonly=True),
3802 }
3803
3804 _defaults = {
3805@@ -608,20 +673,23 @@
3806 # Prepare some values
3807 for cl in self.browse(cr, uid, ids, context=context):
3808 # Browse distribution
3809+ sign = 1
3810+ if cl.commit_id.cv_flow_type == 'customer':
3811+ sign = -1
3812 distrib_id = cl.analytic_distribution_id and cl.analytic_distribution_id.id or False
3813 if not distrib_id:
3814 distrib_id = cl.commit_id and cl.commit_id.analytic_distribution_id and cl.commit_id.analytic_distribution_id.id or False
3815 if distrib_id:
3816 analytic_line_ids = self.pool.get('account.analytic.line').search(cr, uid, [('commitment_line_id', '=', cl.id)], context=context)
3817 self.pool.get('account.analytic.line').unlink(cr, uid, analytic_line_ids, context=context)
3818- ref = cl.commit_id and cl.commit_id.purchase_id and cl.commit_id.purchase_id.name or False
3819+ ref = cl.commit_id and cl.commit_id.purchase_id and cl.commit_id.purchase_id.name or cl.commit_id.sale_id and cl.commit_id.sale_id.name or False
3820 if cl.commit_id:
3821 desc = cl.commit_id.description or cl.commit_id.name
3822 else:
3823 desc = 'Commitment voucher line'
3824 self.pool.get('analytic.distribution').\
3825 create_account_analytic_lines(cr, uid, [distrib_id], desc,
3826- cl.commit_id.date, amount, cl.commit_id.journal_id.id, cl.commit_id.currency_id.id,
3827+ cl.commit_id.date, sign * amount, cl.commit_id.journal_id.id, cl.commit_id.currency_id.id,
3828 cl.commit_id and cl.commit_id.date or False, ref, cl.commit_id.date,
3829 account_id or cl.account_id.id, move_id=False, invoice_line_id=False,
3830 commitment_line_id=cl.id, context=context)
3831@@ -678,15 +746,16 @@
3832 account = self.pool.get('account.account').browse(cr, uid, [account_id], context=context)[0]
3833 if account.type in ['view']:
3834 raise osv.except_osv(_('Error'), _("You cannot write a commitment voucher line on a 'view' account type!"))
3835- # Verify amount validity
3836- if 'amount' in vals and vals.get('amount', 0.0) < 0.0:
3837- raise osv.except_osv(_('Warning'), _('Amount Left should be equal or superior to 0!'))
3838- if 'initial_amount' in vals and vals.get('initial_amount', 0.0) <= 0.0:
3839- raise osv.except_osv(_('Warning'), _('Initial Amount should be superior to 0!'))
3840 # Update analytic distribution if needed and initial_amount
3841 for line in self.browse(cr, uid, ids, context=context):
3842+ # Verify amount validity
3843+ if 'amount' in vals and vals.get('amount', 0.0) < 0.0:
3844+ raise osv.except_osv(_('Warning'), _('Amount Left should be equal or superior to 0!'))
3845+ if 'initial_amount' in vals and vals.get('initial_amount', 0.0) <= 0.0:
3846+ raise osv.except_osv(_('Warning'), _('Initial Amount should be superior to 0!'))
3847+ message = _('Initial Amount should be superior to Amount Left')
3848+
3849 # verify that initial amount is superior to amount left
3850- message = _('Initial Amount should be superior to Amount Left')
3851 if 'amount' in vals and 'initial_amount' in vals:
3852 if vals.get('initial_amount') < vals.get('amount'):
3853 raise osv.except_osv(_('Warning'), message)
3854@@ -783,5 +852,32 @@
3855 'context': context,
3856 }
3857
3858+ def _update_so_commitment_line(self, cr, uid, id, amount, from_cancel=True, context=None):
3859+ """
3860+ reduce amount on CV line from SO
3861+ called when:
3862+ * FO line is canceled(-r)
3863+ * SI is opened or canceled
3864+ """
3865+ if context is None:
3866+ context = {}
3867+ wf_service = netsvc.LocalService("workflow")
3868+ cv_obj = self.pool.get('account.commitment')
3869+
3870+ cv_line = self.browse(cr, uid, id, context=context)
3871+ if not from_cancel and cv_line.commit_id.state == 'draft':
3872+ wf_service.trg_validate(uid, 'account.commitment', cv_line.commit_id.id, 'commitment_open', cr)
3873+
3874+ amount_left = max(round(cv_line.amount - amount, 2), 0)
3875+ # this will trigger AJIs update
3876+ self.write(cr, uid, [id], {'amount': amount_left}, context=context)
3877+
3878+ cv = cv_obj.read(cr, uid, cv_line.commit_id.id, ['total'], context=context)
3879+ if abs(cv['total']) < 0.001:
3880+ cv_obj.action_commitment_done(cr, uid, [cv_line.commit_id.id], context=context)
3881+
3882+ return True
3883+
3884+
3885 account_commitment_line()
3886 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
3887
3888=== modified file 'bin/addons/analytic_distribution/account_commitment_view.xml'
3889--- bin/addons/analytic_distribution/account_commitment_view.xml 2021-08-25 14:50:30 +0000
3890+++ bin/addons/analytic_distribution/account_commitment_view.xml 2021-11-03 13:33:55 +0000
3891@@ -8,12 +8,15 @@
3892 <field name="model">account.commitment</field>
3893 <field name="type">form</field>
3894 <field name="arch" type="xml">
3895- <form string="Commitment Voucher" hide_duplicate_button="1">
3896+ <form string="Supplier Commitment Voucher" hide_duplicate_button="1">
3897 <group col="6" colspan="4">
3898 <field name="journal_id" domain="[('is_current_instance','=',True)]"/>
3899- <field name="partner_id" context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}" attrs="{'readonly': ['|', ('type', '!=', 'manual'), ('state', '!=', 'draft')]}"/>
3900+ <field name="partner_id" context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}" attrs="{'readonly': ['|', ('type', '!=', 'manual'), ('state', '!=', 'draft')]}" string="Supplier"/>
3901 <newline/>
3902 <field name="name"/>
3903+ <field name="cv_flow_type" invisible="1" />
3904+ <field name="purchase_id" attrs="{'invisible': [('cv_flow_type', '!=', 'supplier')]}"/>
3905+ <field name="sale_id" attrs="{'invisible': [('cv_flow_type', '!=', 'customer')]}"/>
3906 <newline/>
3907 <field name="date" on_change="onchange_date(date, period_id)"/>
3908 <field name="period_id"/>
3909@@ -54,7 +57,7 @@
3910 'readonly': [('type', 'in', ['external', 'intermission', 'intersection'])]}"
3911 />
3912 <!-- button which allows to always set a CV to Done (whatever its state and origin) -->
3913- <button name="commitment_always_validate" string="Done (for Administrator only)"
3914+ <button name="commitment_always_validate" string="Force Done"
3915 icon="terp-gtk-go-back-rtl" colspan="6"
3916 confirm='You are about to set this Commitment Voucher to the state "Done". Do you want to proceed?'
3917 attrs="{'invisible': [('display_super_done_button', '=', False)]}"/>
3918@@ -70,10 +73,11 @@
3919 <field name="model">account.commitment</field>
3920 <field name="type">tree</field>
3921 <field name="arch" type="xml">
3922- <tree string="Commitment Voucher" colors="blue:state == 'draft';grey:state == 'done';black:state == 'open'">
3923+ <tree string="Supplier Commitment Vouchers" colors="blue:state == 'draft';grey:state == 'done';black:state == 'open'">
3924 <field name="date"/>
3925 <field name="name"/>
3926- <field name="partner_id"/>
3927+ <field name="partner_id" string="Supplier"/>
3928+ <field name="purchase_id" />
3929 <field name="currency_id"/>
3930 <field name="total" digits="(16,2)"/>
3931 <field name="type"/>
3932@@ -83,6 +87,7 @@
3933 </field>
3934 </record>
3935
3936+
3937 <!-- Commitment Lines -->
3938 <record model="ir.ui.view" id="account_commitment_line_tree">
3939 <field name="name">account.commitment.line.tree</field>
3940@@ -95,8 +100,8 @@
3941 hide_delete_button="1"
3942 >
3943 <field name="commit_type"/>
3944- <field name="po_line_product_id"/>
3945- <field name="po_line_number"/>
3946+ <field name="line_product_id"/>
3947+ <field name="line_number"/>
3948 <field name="account_id" domain="[('restricted_area', '=', 'commitment_lines')]"/>
3949 <button name="button_analytic_distribution" string="Analytical Distribution" type="object"
3950 icon="terp-stock_symbol-selection" context="context"
3951@@ -125,21 +130,21 @@
3952 <field name="model">account.commitment</field>
3953 <field name="type">search</field>
3954 <field name="arch" type="xml">
3955- <search string="Search Commitment Voucher">
3956+ <search string="Supplier Commitment Vouchers">
3957 <group col='6' colspan='4'>
3958- <filter icon="terp-tools" string="Manual" domain="[('type','=','manual')]" help="Manual Commitment Voucher"/>
3959- <filter icon="gtk-quit" string="External" domain="[('type','=','external')]" help="External Commitment Voucher"/>
3960- <filter icon="gtk-refresh" string="Intersection" domain="[('type', '=', 'intersection')]" help="Intersection Commitment Voucher"/>
3961- <filter icon="gtk-ok" string="Intermission" domain="[('type', '=', 'intermission')]" help="Intermission Commitment Voucher"/>
3962- <filter icon="terp-partner" string="ESC" domain="[('type','=','esc')]" help="ESC Commitment Voucher"/>
3963+ <filter icon="terp-tools" string="Manual" domain="[('type','=','manual')]" help="Manual Commitment Vouchers"/>
3964+ <filter icon="gtk-quit" string="External" domain="[('type','=','external')]" help="External Commitment Vouchers"/>
3965+ <filter icon="gtk-refresh" string="Intersection" domain="[('type', '=', 'intersection')]" help="Intersection Commitment Vouchers"/>
3966+ <filter icon="gtk-ok" string="Intermission" domain="[('type', '=', 'intermission')]" help="Intermission Commitment Vouchers"/>
3967+ <filter icon="terp-partner" string="ESC" domain="[('type','=','esc')]" help="ESC Commitment Vouchers"/>
3968 <separator orientation="vertical"/>
3969- <filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Commitment Voucher in Draft state" name="draft"/>
3970- <filter icon="terp-camera_test" string="Validated" domain="[('state','=','open')]" help="Commitment Voucher in Validated state" name="validated"/>
3971- <filter icon="terp-dialog-close" string="Done" domain="[('state','=','done')]" help="Commitment Voucher in Done state" name="done"/>
3972+ <filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Commitment Vouchers in Draft state" name="draft"/>
3973+ <filter icon="terp-camera_test" string="Validated" domain="[('state','=','open')]" help="Commitment Vouchers in Validated state" name="validated"/>
3974+ <filter icon="terp-dialog-close" string="Done" domain="[('state','=','done')]" help="Commitment Vouchers in Done state" name="done"/>
3975 <newline/>
3976 <field name="currency_id" select="1"/>
3977 <field name="date" select='1'/>
3978- <field name="partner_id" select='1'/>
3979+ <field name="partner_id" select="1" string="Supplier" context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}"/>
3980 <field name="name" select="1"/>
3981 <field name="purchase_id"/>
3982 </group>
3983@@ -148,6 +153,95 @@
3984 </field>
3985 </record>
3986
3987+ <!-- Dedicated from FO views: duplicate CV from PO view and replace fields -->
3988+ <record model="ir.ui.view" id="account_commitment_fo_tree_copy">
3989+ <field name="name">account.commitment.fo.tree.copy</field>
3990+ <field name="model">account.commitment</field>
3991+ <field name="type">tree</field>
3992+ <field name="priority" eval="150" />
3993+ <field name="duplicate_view_id" ref="account_commitment_tree" />
3994+ <field name="arch" type="xml">
3995+ <tree />
3996+ </field>
3997+ </record>
3998+ <record model="ir.ui.view" id="account_commitment_fo_tree">
3999+ <field name="name">account.commitment.fo.tree.copy.inherit</field>
4000+ <field name="model">account.commitment</field>
4001+ <field name="type">tree</field>
4002+ <field name="priority" eval="160" />
4003+ <field name="inherit_id" ref="account_commitment_fo_tree_copy" />
4004+ <field name="arch" type="xml">
4005+ <xpath expr="/tree" position="attributes">
4006+ <attribute name="string">Customer Commitment Vouchers</attribute>
4007+ </xpath>
4008+ <xpath expr="//field[@name='purchase_id']" position="replace">
4009+ <field name="sale_id" />
4010+ </xpath>
4011+ <xpath expr="//field[@name='partner_id']" position="attributes">
4012+ <attribute name="string">Customer</attribute>
4013+ </xpath>
4014+ </field>
4015+ </record>
4016+
4017+ <record model="ir.ui.view" id="account_commitment_fo_search_copy">
4018+ <field name="name">account.commitment.fo.search.copy</field>
4019+ <field name="model">account.commitment</field>
4020+ <field name="type">search</field>
4021+ <field name="priority" eval="150" />
4022+ <field name="duplicate_view_id" ref="account_commitment_search" />
4023+ <field name="arch" type="xml">
4024+ <search />
4025+ </field>
4026+ </record>
4027+ <record model="ir.ui.view" id="account_commitment_fo_search">
4028+ <field name="name">account.commitment.fo.seach.copy.inherit</field>
4029+ <field name="model">account.commitment</field>
4030+ <field name="type">tree</field>
4031+ <field name="priority" eval="160" />
4032+ <field name="inherit_id" ref="account_commitment_fo_search_copy" />
4033+ <field name="arch" type="xml">
4034+ <xpath expr="/search" position="attributes">
4035+ <attribute name="string">Customer Commitment Vouchers</attribute>
4036+ </xpath>
4037+ <xpath expr="//field[@name='purchase_id']" position="replace">
4038+ <field name="sale_id" />
4039+ </xpath>
4040+ <xpath expr="//field[@name='partner_id']" position="attributes">
4041+ <attribute name="context">{'default_customer': 1, 'search_default_customer': 1, 'default_supplier': 0}</attribute>
4042+ <attribute name="string">Customer</attribute>
4043+ </xpath>
4044+ <xpath expr="//filter[@string='External']" position="replace" />
4045+ <xpath expr="//filter[@string='ESC']" position="replace" />
4046+ </field>
4047+ </record>
4048+
4049+ <record model="ir.ui.view" id="account_commitment_fo_form_copy">
4050+ <field name="name">account.commitment.fo.form.copy</field>
4051+ <field name="model">account.commitment</field>
4052+ <field name="type">form</field>
4053+ <field name="priority" eval="160" />
4054+ <field name="duplicate_view_id" ref="account_commitment_form" />
4055+ <field name="arch" type="xml">
4056+ <form />
4057+ </field>
4058+ </record>
4059+ <record model="ir.ui.view" id="account_commitment_fo_form">
4060+ <field name="name">account.commitment.fo.form.copy.inherit</field>
4061+ <field name="model">account.commitment</field>
4062+ <field name="type">form</field>
4063+ <field name="priority" eval="160" />
4064+ <field name="inherit_id" ref="account_commitment_fo_form_copy" />
4065+ <field name="arch" type="xml">
4066+ <xpath expr="/form" position="attributes">
4067+ <attribute name="string">Customer Commitment Voucher</attribute>
4068+ </xpath>
4069+ <xpath expr="//field[@name='partner_id']" position="attributes">
4070+ <attribute name="context">{'default_customer': 1, 'search_default_customer': 1, 'default_supplier': 0}</attribute>
4071+ <attribute name="string">Customer</attribute>
4072+ </xpath>
4073+ </field>
4074+ </record>
4075+
4076 <!-- Commitment Import view -->
4077 <record id="import_commitment_wizard_view" model="ir.ui.view">
4078 <field name="name">Import Intl Commitments</field>
4079@@ -252,16 +346,40 @@
4080 </field>
4081 </record>
4082
4083- <!-- Commitment Voucher Actions -->
4084+ <!-- Commitment Voucher Actions from PO -->
4085 <record model="ir.actions.act_window" id="action_account_commitment_tree">
4086 <field name="res_model">account.commitment</field>
4087 <field name="view_type">form</field>
4088 <field name="view_mode">tree,form</field>
4089 <field name="view_id" ref="account_commitment_tree"/>
4090 <field name="search_view_id" ref="account_commitment_search"/>
4091+ <field name="domain">[('cv_flow_type', '=', 'supplier')]</field>
4092 <!-- US-2704 if a domain is added here, do not forget to update the domain of account_board_commitment_voucher in finance/board_account_view.xml -->
4093 <field name="context">{'search_default_draft': 1, 'search_default_validated': 1, 'target_filename_prefix': 'Commitment Vouchers'}</field>
4094 </record>
4095+
4096+ <!-- Commitment Voucher Actions from FO -->
4097+ <record model="ir.actions.act_window" id="action_account_commitment_from_fo">
4098+ <field name="res_model">account.commitment</field>
4099+ <field name="view_type">form</field>
4100+ <field name="view_mode">tree,form</field>
4101+ <field name="search_view_id" ref="account_commitment_fo_search_copy"/>
4102+ <field name="domain">[('cv_flow_type', '=', 'customer')]</field>
4103+ <field name="context">{'search_default_draft': 1, 'search_default_validated': 1, 'target_filename_prefix': 'Commitment Vouchers'}</field>
4104+ </record>
4105+ <record model="ir.actions.act_window.view" id="action_account_commitment_from_fo_tree">
4106+ <field name="sequence" eval="10"/>
4107+ <field name="view_mode">tree</field>
4108+ <field name="view_id" ref="account_commitment_fo_tree_copy"/>
4109+ <field name="act_window_id" ref="action_account_commitment_from_fo"/>
4110+ </record>
4111+ <record model="ir.actions.act_window.view" id="action_account_commitment_from_fo_form">
4112+ <field name="sequence" eval="20"/>
4113+ <field name="view_mode">form</field>
4114+ <field name="view_id" ref="account_commitment_fo_form_copy"/>
4115+ <field name="act_window_id" ref="action_account_commitment_from_fo"/>
4116+ </record>
4117+
4118
4119 <!-- next 2 views: duplicate AJI form/tree for commitment Lines (only used to link dedicated sidebar entries -->
4120 <record id="view_account_analytic_line_tree_commline" model="ir.ui.view">
4121@@ -337,9 +455,10 @@
4122
4123 <!-- Menu -->
4124 <menuitem id="menu_commitment" name="Commitments" parent="account.menu_finance" sequence="4"/>
4125- <menuitem name="Commitment Voucher" action="action_account_commitment_tree" id="menu_commitment_entries" parent="menu_commitment" sequence="1"/>
4126- <menuitem name="Commitment Lines" action="action_engagement_line_tree" id="menu_engagement_lines" parent="menu_commitment" sequence="2"/>
4127- <menuitem name="Import Intl Commitments" action="action_import_commitment_wizard" id="menu_import_commitment" parent="menu_commitment" sequence="3"/>
4128+ <menuitem name="Customer Commitment Vouchers" action="action_account_commitment_from_fo" id="menu_account_commitment_from_fo" parent="menu_commitment" sequence="10"/>
4129+ <menuitem name="Supplier Commitment Vouchers" action="action_account_commitment_tree" id="menu_commitment_entries" parent="menu_commitment" sequence="20"/>
4130+ <menuitem name="Commitment Lines" action="action_engagement_line_tree" id="menu_engagement_lines" parent="menu_commitment" sequence="30"/>
4131+ <menuitem name="Import Intl Commitments" action="action_import_commitment_wizard" id="menu_import_commitment" parent="menu_commitment" sequence="40"/>
4132
4133 </data>
4134
4135
4136=== modified file 'bin/addons/analytic_distribution/account_invoice_refund.py'
4137--- bin/addons/analytic_distribution/account_invoice_refund.py 2019-06-24 14:40:19 +0000
4138+++ bin/addons/analytic_distribution/account_invoice_refund.py 2021-11-03 13:33:55 +0000
4139@@ -33,7 +33,6 @@
4140 """
4141 WARNING: This method has been taken from account module from OpenERP
4142 """
4143- # @@@override@account.wizard.account_invoice_refund.py
4144 obj_journal = self.pool.get('account.journal')
4145 obj_inv = self.pool.get('account.invoice')
4146 user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
4147@@ -43,8 +42,16 @@
4148 # in case of a DI refund from a register line use the dir_invoice_id in context
4149 doc_to_refund_id = context.get('dir_invoice_id', False) or (context.get('active_ids') and context['active_ids'][0])
4150 if doc_to_refund_id:
4151- source = obj_inv.read(cr, uid, doc_to_refund_id, ['type', 'is_intermission'], context=context)
4152- if source['is_intermission']:
4153+ source = obj_inv.read(cr, uid, doc_to_refund_id, ['type', 'is_intermission', 'doc_type', 'journal_id'], context=context)
4154+ if source['doc_type'] == 'stv':
4155+ if source['journal_id']:
4156+ # by default use the same journal for the refund
4157+ args = [('id', '=', source['journal_id'][0])]
4158+ else:
4159+ args = [('type', '=', 'sale')]
4160+ elif source['doc_type'] == 'isi':
4161+ args = [('type', '=', 'purchase'), ('code', '=', 'ISI')]
4162+ elif source['is_intermission']:
4163 args = [('type', '=', 'intermission')]
4164 elif source['type'] in ('in_invoice', 'in_refund'):
4165 args = [('type', '=', 'purchase_refund')]
4166@@ -69,17 +76,24 @@
4167 context = {}
4168 journal_obj = self.pool.get('account.journal')
4169 res = super(account_invoice_refund,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
4170- jtype = 'sale_refund'
4171- if context.get('journal_type'):
4172- jtype = isinstance(context['journal_type'], list) and context['journal_type'][0] or context['journal_type']
4173- if jtype in ('sale', 'sale_refund'):
4174+ if context.get('doc_type', '') == 'stv':
4175+ jtype = 'sale'
4176+ elif context.get('doc_type', '') == 'isi':
4177+ jtype = 'purchase'
4178+ else:
4179 jtype = 'sale_refund'
4180- elif jtype != 'intermission': # for IVO/IVI keep using the Interm. journal
4181- jtype = 'purchase_refund'
4182+ if context.get('journal_type'):
4183+ jtype = isinstance(context['journal_type'], list) and context['journal_type'][0] or context['journal_type']
4184+ if jtype in ('sale', 'sale_refund'):
4185+ jtype = 'sale_refund'
4186+ elif jtype != 'intermission': # for IVO/IVI keep using the Interm. journal
4187+ jtype = 'purchase_refund'
4188 user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
4189 for field in res['fields']:
4190 if field == 'journal_id' and user.company_id.instance_id:
4191 journal_domain = [('type', '=', jtype), ('is_current_instance', '=', True)]
4192+ if context.get('doc_type', '') == 'isi':
4193+ journal_domain.append(('code', '=', 'ISI'))
4194 journal_select = journal_obj._name_search(cr, uid, '', journal_domain, context=context, limit=None, name_get_uid=1)
4195 res['fields'][field]['selection'] = journal_select
4196 res['fields'][field]['domain'] = journal_domain
4197@@ -88,7 +102,9 @@
4198 _columns = {
4199 'date': fields.date('Posting date'),
4200 'document_date': fields.date('Document Date', required=True),
4201- 'is_intermission': fields.boolean("Wizard opened from an Intermission Voucher", readonly=True)
4202+ 'is_intermission': fields.boolean("Wizard opened from an Intermission Voucher", readonly=True),
4203+ 'is_stv': fields.boolean("Wizard opened from a Stock Transfer Voucher", readonly=True),
4204+ 'is_isi': fields.boolean("Wizard opened from an Intersection Supplier Invoice", readonly=True),
4205 }
4206
4207 def _get_refund(self, cr, uid, context=None):
4208@@ -97,8 +113,10 @@
4209 """
4210 if context is None:
4211 context = {}
4212- if context.get('is_intermission', False):
4213+ if context.get('is_intermission', False) or context.get('doc_type', '') == 'stv':
4214 return 'modify'
4215+ elif context.get('doc_type', '') == 'isi':
4216+ return 'cancel'
4217 return 'refund' # note that only the "Refund" option is available in DI
4218
4219 def _get_is_intermission(self, cr, uid, context=None):
4220@@ -109,11 +127,29 @@
4221 context = {}
4222 return context.get('is_intermission', False)
4223
4224+ def _get_is_stv(self, cr, uid, context=None):
4225+ """
4226+ Returns True if the wizard has been opened from a Stock Transfer Voucher
4227+ """
4228+ if context is None:
4229+ context = {}
4230+ return context.get('doc_type', '') == 'stv'
4231+
4232+ def _get_is_isi(self, cr, uid, context=None):
4233+ """
4234+ Returns True if the wizard has been opened from an Intersection Supplier Invoice
4235+ """
4236+ if context is None:
4237+ context = {}
4238+ return context.get('doc_type', '') == 'isi'
4239+
4240 _defaults = {
4241 'document_date': _get_document_date,
4242 'filter_refund': _get_refund,
4243 'journal_id': _get_journal, # US-193
4244 'is_intermission': _get_is_intermission,
4245+ 'is_stv': _get_is_stv,
4246+ 'is_isi': _get_is_isi,
4247 }
4248
4249 def _hook_fields_for_modify_refund(self, cr, uid, *args):
4250@@ -143,7 +179,7 @@
4251 else:
4252 return self.pool.get('account.invoice').refund(cr, uid, inv_ids, date, period, description, journal_id, context=context)
4253
4254- def _hook_create_invoice(self, cr, uid, data, form, *args):
4255+ def _hook_create_invoice(self, cr, uid, data, form, context=None):
4256 """
4257 Permits to adapt invoice creation
4258 """
4259@@ -151,7 +187,7 @@
4260 self.pool.get('finance.tools').check_document_date(cr, uid,
4261 form['document_date'], form['date'])
4262 data.update({'document_date': form['document_date']})
4263- return super(account_invoice_refund, self)._hook_create_invoice(cr, uid, data, form)
4264+ return super(account_invoice_refund, self)._hook_create_invoice(cr, uid, data, form, context=context)
4265
4266 def _hook_get_period_from_date(self, cr, uid, invoice_id, date=False, period=False):
4267 """
4268
4269=== modified file 'bin/addons/analytic_distribution/account_invoice_view.xml'
4270--- bin/addons/analytic_distribution/account_invoice_view.xml 2020-01-21 14:01:11 +0000
4271+++ bin/addons/analytic_distribution/account_invoice_view.xml 2021-11-03 13:33:55 +0000
4272@@ -2,70 +2,6 @@
4273 <openerp>
4274 <data>
4275
4276- <!-- Add new analytic distribution button -->
4277- <record id="invoice_supplier_form_2" model="ir.ui.view">
4278- <field name="name">account.invoice.supplier.form.2</field>
4279- <field name="model">account.invoice</field>
4280- <field name="type">form</field>
4281- <field name="inherit_id" ref="account.invoice_supplier_form"/>
4282- <field name="priority">30</field>
4283- <field name="arch" type="xml">
4284- <data>
4285- <xpath expr="/form/notebook" position="before">
4286- <newline />
4287- <group colspan="4" col="8" attrs="{'invisible': [('analytic_distribution_id', '=', False)]}">
4288- <button name="button_analytic_distribution" string="Analytical Distribution" type="object" icon="terp-check" context="context" colspan="4" attrs="{'invisible': [('analytic_distribution_id', '=', False)]}"/>
4289- <button name="button_reset_distribution" string="Reset AD at line level" type="object" icon="gtk-undelete" colspan="4" states="draft"/>
4290- </group>
4291- <group colspan="4" col="8" attrs="{'invisible': [('analytic_distribution_id', '!=', False)]}">
4292- <button name="button_analytic_distribution" string="Analytical Distribution" type="object" icon="terp-emblem-important" context="context" colspan="4" attrs="{'invisible': [('analytic_distribution_id', '!=', False)]}"/>
4293- <button name="button_reset_distribution" string="Reset AD at line level" type="object" icon="gtk-undelete" colspan="4" states="draft"/>
4294- </group>
4295- <field name="analytic_distribution_id" invisible="1"/>
4296- <group colspan="3"/>
4297- </xpath>
4298- <xpath expr="//tree[@string='Invoice lines']/field[@name='account_analytic_id']" position="replace">
4299- <field name="inactive_product" invisible="1" />
4300- <button name="button_analytic_distribution" string="Analytical Distribution" type="object" icon="terp-stock_symbol-selection" context="context" attrs="{'invisible': [('is_allocatable', '=', False)]}"/>
4301- <field name="analytic_distribution_state_recap"/>
4302- <field name="have_analytic_distribution_from_header" invisible="1"/>
4303- <field name="analytic_distribution_state" invisible="1"/>
4304- <field name="is_allocatable" invisible="1"/>
4305- </xpath>
4306- <xpath expr="//tree[@string='Invoice lines']" position="attributes">
4307- <attribute name="colors">red:analytic_distribution_state in ('invalid', 'invalid_small_amount') or inactive_product == True;black:analytic_distribution_state in ('none','valid') and inactive_product == False</attribute>
4308- </xpath>
4309- <xpath expr="//tree[@string='Invoice lines']/field[@name='product_id']" position="before">
4310- <field name="is_corrected" invisible="1"/>
4311- <button name="button_open_analytic_lines" string="Have been corrected" type="object" icon="terp-mail-" attrs="{'invisible': [('is_corrected', '=', False)]}"/>
4312- </xpath>
4313- </data>
4314- </field>
4315- </record>
4316-
4317- <record id="invoice_form_2" model="ir.ui.view">
4318- <field name="name">account.invoice.supplier.form.2</field>
4319- <field name="model">account.invoice</field>
4320- <field name="type">form</field>
4321- <field name="inherit_id" ref="account.invoice_form"/>
4322- <field name="priority">35</field>
4323- <field name="arch" type="xml">
4324- <data>
4325- <xpath expr="/form/notebook" position="before">
4326- <group colspan="4" col="8" attrs="{'invisible': [('analytic_distribution_id', '=', False)]}">
4327- <button name="button_analytic_distribution" string="Analytical Distribution" type="object" icon="terp-check" context="context" colspan="4" attrs="{'invisible': [('analytic_distribution_id', '=', False)]}"/>
4328- <button name="button_reset_distribution" string="Reset AD at line level" type="object" icon="gtk-undelete" colspan="4" states="draft"/>
4329- </group>
4330- <group colspan="4" col="8" attrs="{'invisible': [('analytic_distribution_id', '!=', False)]}">
4331- <button name="button_analytic_distribution" string="Analytical Distribution" type="object" icon="terp-emblem-important" context="context" colspan="4" attrs="{'invisible': [('analytic_distribution_id', '!=', False)]}"/>
4332- <button name="button_reset_distribution" string="Reset AD at line level" type="object" icon="gtk-undelete" colspan="4" states="draft"/>
4333- </group>
4334- <field name="analytic_distribution_id" invisible="1"/>
4335- <group colspan="3"/>
4336- </xpath>
4337- </data>
4338- </field>
4339- </record>
4340
4341 <record id="view_invoice_line_tree_2" model="ir.ui.view">
4342 <field name="name">account.invoice.line.tree.2</field>
4343@@ -122,7 +58,11 @@
4344 <xpath expr="//field[@name='invoice_line_tax_id']" position="replace">
4345 <field name="vat_ok" invisible="1" />
4346 <field name="synced" invisible="1" />
4347- <group colspan="4" col="4" attrs="{'invisible': [('vat_ok', '=', False)]}">
4348+ <field name="line_doc_type" invisible="1" />
4349+ <!-- note: in STV and STR taxes are hidden even for external partners as these are in fact "false" external partners
4350+ (e.g. instances for which the deployment of UniField hasn't been finished) -->
4351+ <group colspan="4" col="4"
4352+ attrs="{'invisible': ['|', ('vat_ok', '=', False), ('line_doc_type', 'in', ('stv', 'str', 'isi', 'isr'))]}">
4353 <separator colspan="4" string="Taxes"/>
4354 <field colspan="4"
4355 name="invoice_line_tax_id"
4356
4357=== modified file 'bin/addons/analytic_distribution/account_view.xml'
4358--- bin/addons/analytic_distribution/account_view.xml 2021-09-07 16:24:58 +0000
4359+++ bin/addons/analytic_distribution/account_view.xml 2021-11-03 13:33:55 +0000
4360@@ -42,38 +42,6 @@
4361 </field>
4362 </record>
4363
4364- <record id="view_account_form" model="ir.ui.view">
4365- <field name="name">account.form</field>
4366- <field name="model">account.account</field>
4367- <field name="type">form</field>
4368- <field name="inherit_id" ref="account.view_account_form"/>
4369- <field name="priority">25</field>
4370- <field name="arch" type="xml">
4371- <data>
4372- <xpath expr="//field[@name='user_type']" position="replace">
4373- <field name="user_type_code" invisible="1"/>
4374- <field name="is_analytic_addicted" invisible="1"/>
4375- <field name="user_type" on_change="onchange_user_type(user_type, code)"/>
4376- </xpath>
4377- <xpath expr="/form/notebook/page[@string='General Information']" position="after">
4378- <page string="Analytical Destination">
4379- <field name="default_destination_id" colspan="2"
4380- attrs="{'required': [('is_analytic_addicted', '=', True)], 'readonly': [('is_analytic_addicted', '!=', True)]}"/>
4381- <label string="" colspan="2"/>
4382- <field name="destination_ids" nolabel="1" colspan="4" domain="[('type', '!=', 'view'), ('category', '=', 'DEST')]">
4383- <tree string="Destinations">
4384- <field name="name"/>
4385- <field name="description"/>
4386- <field name="date_start"/>
4387- <field name="date"/>
4388- </tree>
4389- </field>
4390- </page>
4391- </xpath>
4392- </data>
4393- </field>
4394- </record>
4395-
4396 <record id="analytic_view_move_form" model="ir.ui.view">
4397 <field name="name">analytic.view.move.form</field>
4398 <field name="model">account.move</field>
4399
4400=== modified file 'bin/addons/analytic_distribution/analytic_line_view.xml'
4401--- bin/addons/analytic_distribution/analytic_line_view.xml 2016-09-28 08:20:24 +0000
4402+++ bin/addons/analytic_distribution/analytic_line_view.xml 2021-11-03 13:33:55 +0000
4403@@ -2,42 +2,6 @@
4404 <openerp>
4405 <data>
4406
4407- <!-- Add icon ahead analytic line to inform if this line have been reallocated or not -->
4408- <record id="inherit2_view_account_analytic_line_tree" model="ir.ui.view">
4409- <field name="name">account.analytic.line.tree</field>
4410- <field name="model">account.analytic.line</field>
4411- <field name="type">tree</field>
4412- <field name="inherit_id" ref="account.view_account_analytic_line_tree"/>
4413- <field name="priority" eval="11"/>
4414- <field name="arch" type="xml">
4415- <data>
4416- <xpath expr="/tree/field[@name='move_id']" position='replace'>
4417- <field name="entry_sequence"/>
4418- </xpath>
4419- <xpath expr="/tree/field[@name='functional_currency_id']" position="after">
4420- <field name="output_amount"/>
4421- <field name="output_currency"/>
4422- </xpath>
4423- </data>
4424- </field>
4425- </record>
4426-
4427- <!-- View for Analytic Journal Items (FUNDING POOL) -->
4428- <record id="view_account_analytic_line_tree" model="ir.ui.view">
4429- <field name="name">account.analytic.line.tree</field>
4430- <field name="model">account.analytic.line</field>
4431- <field name="type">tree</field>
4432- <field name="inherit_id" ref="account.view_account_analytic_line_tree"/>
4433- <field name="priority" eval="12"/>
4434- <field name="arch" type="xml">
4435- <data>
4436- <xpath expr="/tree/field[@name='account_id']" position='before'>
4437- <field name="destination_id" string="Destination" invisible="not context.get('display_fp', False)"/>
4438- <field name="cost_center_id" string="Cost Center" invisible="not context.get('display_fp', False)"/>
4439- </xpath>
4440- </data>
4441- </field>
4442- </record>
4443
4444 <!-- Action for Analytic Journal Items (FUNDING POOL) -->
4445 <record id="account.action_account_analytic_journal_open_form" model="ir.actions.act_window">
4446@@ -45,7 +9,7 @@
4447 <field name="res_model">account.analytic.line</field>
4448 <field name="view_type">form</field>
4449 <field name="view_mode">tree,form</field>
4450- <field name="view_id" ref="view_account_analytic_line_tree"/>
4451+ <field name="view_id" ref="account.view_account_analytic_line_tree"/>
4452 <field name="domain">[('account_id.category', '=', 'FUNDING')]</field>
4453 <field name="context">{'display_fp': True, 'target_filename_prefix': 'Analytic Journal Items'}</field>
4454 </record>
4455@@ -60,7 +24,7 @@
4456 <field name="res_model">account.analytic.line</field>
4457 <field name="view_type">form</field>
4458 <field name="view_mode">tree,form</field>
4459- <field name="view_id" ref="view_account_analytic_line_tree"/>
4460+ <field name="view_id" ref="account.view_account_analytic_line_tree"/>
4461 <field name="domain">[('account_id.category', '=', 'FREE1')]</field>
4462 <field name="context">{'display_fp': False, 'categ': 'FREE1'}</field>
4463 </record>
4464@@ -75,7 +39,7 @@
4465 <field name="res_model">account.analytic.line</field>
4466 <field name="view_type">form</field>
4467 <field name="view_mode">tree,form</field>
4468- <field name="view_id" ref="view_account_analytic_line_tree"/>
4469+ <field name="view_id" ref="account.view_account_analytic_line_tree"/>
4470 <field name="domain">[('account_id.category', '=', 'FREE2')]</field>
4471 <field name="context">{'display_fp': False, 'categ': 'FREE2'}</field>
4472 </record>
4473
4474=== modified file 'bin/addons/analytic_distribution_supply/__openerp__.py'
4475--- bin/addons/analytic_distribution_supply/__openerp__.py 2017-10-04 05:23:42 +0000
4476+++ bin/addons/analytic_distribution_supply/__openerp__.py 2021-11-03 13:33:55 +0000
4477@@ -30,7 +30,6 @@
4478 "depends" : ["base", "account_journal", "analytic_distribution", "purchase_override", "stock", "res_currency_functional"],
4479 "init_xml" : [],
4480 "update_xml" : [
4481- "account_commitment_view.xml",
4482 ],
4483 "demo_xml" : [],
4484 "test": [
4485
4486=== removed file 'bin/addons/analytic_distribution_supply/account_commitment_view.xml'
4487=== modified file 'bin/addons/analytic_distribution_supply/invoice.py'
4488--- bin/addons/analytic_distribution_supply/invoice.py 2021-08-11 12:34:27 +0000
4489+++ bin/addons/analytic_distribution_supply/invoice.py 2021-11-03 13:33:55 +0000
4490@@ -27,7 +27,7 @@
4491 from tools.translate import _
4492 from base import currency_date
4493 import netsvc
4494-
4495+import time
4496
4497 class account_invoice_line(osv.osv):
4498 _name = 'account.invoice.line'
4499@@ -130,38 +130,65 @@
4500 if isinstance(ids, (int, long)):
4501 ids = [ids]
4502
4503+ cv_obj = self.pool.get('account.commitment')
4504+ cv_line_obj = self.pool.get('account.commitment.line')
4505+ curr_obj = self.pool.get('res.currency')
4506+ check_cv_to_close = {}
4507 # Browse invoices
4508 for inv in self.browse(cr, uid, ids, context=context):
4509 grouped_invl_by_acc = {}
4510 grouped_invl_by_cvl = {}
4511- co_ids = self.pool.get('account.commitment').search(cr, uid, [('purchase_id', 'in', [x.id for x in inv.purchase_ids]), ('state', 'in', ['open', 'draft'])], order='date desc', context=context)
4512- if not co_ids:
4513- continue
4514+
4515+ invoice_curr = inv.currency_id.id
4516+
4517+
4518+ cv_on_po = cv_obj.search_exists(cr, uid, [('purchase_id', 'in', [x.id for x in inv.purchase_ids]), ('state', 'in', ['open', 'draft'])], context=context)
4519+ cv_on_fo = False
4520+ if not cv_on_po:
4521+ cv_on_fo = cv_obj.search_exists(cr, uid, [('sale_id', 'in', [x.id for x in inv.order_ids]), ('state', 'in', ['open', 'draft'])], context=context)
4522+ if not cv_on_fo:
4523+ continue
4524
4525 for invl in inv.invoice_line:
4526 # Do not take invoice line that have no order_line_id (so that are not linked to a purchase order line)
4527- if not invl.order_line_id and not inv.is_merged_by_account:
4528- continue
4529- # exclude push flow
4530- if invl.order_line_id and (invl.order_line_id.order_id.push_fo or invl.order_line_id.set_as_sourced_n):
4531- continue
4532- old_cv_version = True
4533+ if cv_on_po:
4534+ if not invl.order_line_id and not inv.is_merged_by_account:
4535+ continue
4536+ # exclude push flow
4537+ if invl.order_line_id and (invl.order_line_id.order_id.push_fo or invl.order_line_id.set_as_sourced_n):
4538+ continue
4539+ old_cv_version = True
4540+ else:
4541+ if not invl.sale_order_line_id:
4542+ continue
4543+ old_cv_version = False
4544+
4545 # CV STARTING FROM VERSION 2
4546 amount_to_subtract = invl.price_subtotal or 0.0
4547 for cv_line in invl.cv_line_ids:
4548 old_cv_version = False # the field cv_line_ids exist for CVs starting from version 2
4549 if abs(amount_to_subtract) <= 10**-3:
4550 break
4551- cvl_amount_left = cv_line.amount or 0.0
4552- if cvl_amount_left:
4553- if cv_line.id not in grouped_invl_by_cvl:
4554- grouped_invl_by_cvl[cv_line.id] = 0
4555- if amount_to_subtract >= cvl_amount_left:
4556- grouped_invl_by_cvl[cv_line.id] += cvl_amount_left
4557- amount_to_subtract -= cvl_amount_left
4558- else:
4559- grouped_invl_by_cvl[cv_line.id] += amount_to_subtract
4560- amount_to_subtract = 0
4561+ if cv_on_fo:
4562+ # no group by accounts on IS/IM SI
4563+ if invoice_curr != cv_line.commit_id.currency_id.id:
4564+ curr_date = currency_date.get_date(self, cr, inv.document_date, inv.date_invoice)
4565+
4566+ amount_to_subtract = curr_obj.compute(cr, uid, invoice_curr, cv_line.commit_id.currency_id.id, amount_to_subtract, round=True,
4567+ context={'currency_date': curr_date or time.strftime('%Y-%m-%d')})
4568+ check_cv_to_close[cv_line.commit_id.id] = True
4569+ cv_line_obj._update_so_commitment_line(cr, uid, cv_line.id, amount_to_subtract, from_cancel=False, context=context)
4570+ else:
4571+ cvl_amount_left = cv_line.amount or 0.0
4572+ if cvl_amount_left:
4573+ if cv_line.id not in grouped_invl_by_cvl:
4574+ grouped_invl_by_cvl[cv_line.id] = 0
4575+ if amount_to_subtract >= cvl_amount_left:
4576+ grouped_invl_by_cvl[cv_line.id] += cvl_amount_left
4577+ amount_to_subtract -= cvl_amount_left
4578+ else:
4579+ grouped_invl_by_cvl[cv_line.id] += amount_to_subtract
4580+ amount_to_subtract = 0
4581 # CV IN VERSION 1
4582 if old_cv_version:
4583 # Fetch purchase order line account
4584@@ -183,9 +210,12 @@
4585 grouped_invl_by_acc[a] = 0
4586 grouped_invl_by_acc[a] += invl.price_subtotal
4587
4588- po_ids = [x.id for x in inv.purchase_ids]
4589- self._update_commitments_lines(cr, uid, po_ids, account_amount_dic=grouped_invl_by_acc,
4590- cvl_amount_dic=grouped_invl_by_cvl, from_cancel=False, context=context)
4591+ if cv_on_po:
4592+ po_ids = [x.id for x in inv.purchase_ids]
4593+ self._update_commitments_lines(cr, uid, po_ids, account_amount_dic=grouped_invl_by_acc,
4594+ cvl_amount_dic=grouped_invl_by_cvl, from_cancel=False, context=context)
4595+ if check_cv_to_close:
4596+ cv_obj.test_and_close_cv_so(cr, uid, check_cv_to_close.keys(), invoice_ids=ids, context=context)
4597
4598 return True
4599
4600@@ -356,17 +386,20 @@
4601 to_process = []
4602 # Verify if all invoice have a po that have a commitment
4603 for inv in self.browse(cr, uid, ids, context=context):
4604- for po in inv.purchase_ids:
4605- if po.commitment_ids:
4606- to_process.append(inv.id)
4607- # UTP-536 : Check if the PO is closed and all SI are draft, then close the CV
4608- po_states = ['done']
4609- if po.order_type == 'direct' and po.po_version == 1:
4610- # DPO v1 specific use case: CV and SI are both created at DPO confirmation
4611- # ==> close the CVs if the DPO is at least "Confirmed" and no SI is in Draft anymore
4612- po_states = ['confirmed', 'confirmed_p', 'done']
4613- if po.state in po_states and all(x.id in ids or x.state != 'draft' for x in po.invoice_ids):
4614- self.pool.get('purchase.order')._finish_commitment(cr, uid, [po.id], context=context)
4615+ if inv.order_ids:
4616+ to_process.append(inv.id)
4617+ else:
4618+ for po in inv.purchase_ids:
4619+ if po.commitment_ids:
4620+ to_process.append(inv.id)
4621+ # UTP-536 : Check if the PO is closed and all SI are draft, then close the CV
4622+ po_states = ['done']
4623+ if po.order_type == 'direct' and po.po_version == 1:
4624+ # DPO v1 specific use case: CV and SI are both created at DPO confirmation
4625+ # ==> close the CVs if the DPO is at least "Confirmed" and no SI is in Draft anymore
4626+ po_states = ['confirmed', 'confirmed_p', 'done']
4627+ if po.state in po_states and all(x.id in ids or x.state != 'draft' for x in po.invoice_ids):
4628+ self.pool.get('purchase.order')._finish_commitment(cr, uid, [po.id], context=context)
4629
4630 # Process invoices
4631 self.update_commitments(cr, uid, to_process, context=context)
4632
4633=== modified file 'bin/addons/base/__openerp__.py'
4634--- bin/addons/base/__openerp__.py 2019-12-12 13:30:26 +0000
4635+++ bin/addons/base/__openerp__.py 2021-11-03 13:33:55 +0000
4636@@ -23,7 +23,7 @@
4637
4638 {
4639 'name': 'Base',
4640- 'version': '1.6',
4641+ 'version': '1.7',
4642 'category': 'Generic Modules/Base',
4643 'description': """The kernel of OpenERP, needed for all installation.""",
4644 'author': 'OpenERP SA',
4645
4646=== modified file 'bin/addons/base/ir/ir_actions.py'
4647--- bin/addons/base/ir/ir_actions.py 2020-02-25 14:52:32 +0000
4648+++ bin/addons/base/ir/ir_actions.py 2021-11-03 13:33:55 +0000
4649@@ -284,7 +284,7 @@
4650 'view_id': fields.many2one('ir.ui.view', 'View Ref.', ondelete='cascade'),
4651 'domain': fields.char('Domain Value', size=250,
4652 help="Optional domain filtering of the destination data, as a Python expression"),
4653- 'context': fields.char('Context Value', size=250, required=True,
4654+ 'context': fields.char('Context Value', size=512, required=True,
4655 help="Context dictionary as Python expression, empty by default (Default: {})"),
4656 'res_model': fields.char('Object', size=64, required=True,
4657 help="Model name of the object to open in the view window"),
4658
4659=== added directory 'bin/addons/base/migrations/8.0.1.7'
4660=== added file 'bin/addons/base/migrations/8.0.1.7/pre-update-bar.py'
4661--- bin/addons/base/migrations/8.0.1.7/pre-update-bar.py 1970-01-01 00:00:00 +0000
4662+++ bin/addons/base/migrations/8.0.1.7/pre-update-bar.py 2021-11-03 13:33:55 +0000
4663@@ -0,0 +1,22 @@
4664+import os
4665+from tools import config
4666+import logging
4667+
4668+
4669+def migrate(cr, version):
4670+ if not cr.table_exists('ir_model_data'):
4671+ return
4672+
4673+ logger = logging.getLogger('migration')
4674+ queries = os.path.join(config['root_path'], 'addons/base/migrations/8.0.1.7/update_bar_sdref.sql')
4675+ if os.path.exists(queries):
4676+ with open(queries) as lines:
4677+ for line in lines:
4678+ if line:
4679+ cr.execute('SAVEPOINT migration')
4680+ try:
4681+ cr.execute(line)
4682+ except:
4683+ logger.warn('SQL error %s' % line)
4684+ cr.execute('ROLLBACK TO SAVEPOINT migration')
4685+ return True
4686
4687=== added file 'bin/addons/base/migrations/8.0.1.7/update_bar_sdref.sql'
4688--- bin/addons/base/migrations/8.0.1.7/update_bar_sdref.sql 1970-01-01 00:00:00 +0000
4689+++ bin/addons/base/migrations/8.0.1.7/update_bar_sdref.sql 2021-11-03 13:33:55 +0000
4690@@ -0,0 +1,108 @@
4691+delete from msf_button_access_rights_button_access_rule where name='button_split_invoice' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_supplier_form_button_split_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4692+delete from ir_model_data where name='BAR_accountinvoice_supplier_form_button_split_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule';
4693+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_supplier_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinvoice_supplier_form_3_button_split_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4694+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_supplier_form_button_split_invoice' where name='BAR_account_overrideinvoice_supplier_form_3_button_split_invoice' and module='sd';
4695+delete from msf_button_access_rights_button_access_rule where name='button_split_invoice' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_button_split_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4696+delete from ir_model_data where name='BAR_accountinvoice_form_button_split_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule';
4697+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinvoice_form_3_button_split_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4698+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_button_split_invoice' where name='BAR_account_overrideinvoice_form_3_button_split_invoice' and module='sd';
4699+delete from msf_button_access_rights_button_access_rule where name='invoice_open' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule');
4700+delete from ir_model_data where name='BAR_accountinvoice_form_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule';
4701+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinherit_invoice_form_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule');
4702+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_invoice_open' where name='BAR_account_overrideinherit_invoice_form_invoice_open' and module='sd';
4703+delete from msf_button_access_rights_button_access_rule where name='button_analytic_distribution' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_supplier_form_button_analytic_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule');
4704+delete from ir_model_data where name='BAR_accountinvoice_supplier_form_button_analytic_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule';
4705+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_supplier_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_analytic_distributioninvoice_supplier_form_2_button_analytic_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule');
4706+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_supplier_form_button_analytic_distribution' where name='BAR_analytic_distributioninvoice_supplier_form_2_button_analytic_distribution' and module='sd';
4707+delete from msf_button_access_rights_button_access_rule where name='button_reset_distribution' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_supplier_form_button_reset_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule');
4708+delete from ir_model_data where name='BAR_accountinvoice_supplier_form_button_reset_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule';
4709+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_supplier_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_analytic_distributioninvoice_supplier_form_2_button_reset_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule');
4710+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_supplier_form_button_reset_distribution' where name='BAR_analytic_distributioninvoice_supplier_form_2_button_reset_distribution' and module='sd';
4711+delete from msf_button_access_rights_button_access_rule where name='button_open_analytic_lines' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_supplier_form_button_open_analytic_lines' and module='sd' and model='msf_button_access_rights.button_access_rule');
4712+delete from ir_model_data where name='BAR_accountinvoice_supplier_form_button_open_analytic_lines' and module='sd' and model='msf_button_access_rights.button_access_rule';
4713+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_supplier_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_analytic_distributioninvoice_supplier_form_2_button_open_analytic_lines' and module='sd' and model='msf_button_access_rights.button_access_rule');
4714+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_supplier_form_button_open_analytic_lines' where name='BAR_analytic_distributioninvoice_supplier_form_2_button_open_analytic_lines' and module='sd';
4715+delete from msf_button_access_rights_button_access_rule where name='button_analytic_distribution' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_button_analytic_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule');
4716+delete from ir_model_data where name='BAR_accountinvoice_form_button_analytic_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule';
4717+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_analytic_distributioninvoice_form_2_button_analytic_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule');
4718+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_button_analytic_distribution' where name='BAR_analytic_distributioninvoice_form_2_button_analytic_distribution' and module='sd';
4719+delete from msf_button_access_rights_button_access_rule where name='button_reset_distribution' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_button_reset_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule');
4720+delete from ir_model_data where name='BAR_accountinvoice_form_button_reset_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule';
4721+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_analytic_distributioninvoice_form_2_button_reset_distribution' and module='sd' and model='msf_button_access_rights.button_access_rule');
4722+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_button_reset_distribution' where name='BAR_analytic_distributioninvoice_form_2_button_reset_distribution' and module='sd';
4723+delete from msf_button_access_rights_button_access_rule where name='invoice_open' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_tree_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule');
4724+delete from ir_model_data where name='BAR_accountinvoice_tree_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule';
4725+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_tree' and module='account') where id in (select res_id from ir_model_data where name='BAR_register_accountinginvoice_tree_2_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule');
4726+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_tree_invoice_open' where name='BAR_register_accountinginvoice_tree_2_invoice_open' and module='sd';
4727+delete from msf_button_access_rights_button_access_rule where name='invoice_open' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule');
4728+delete from ir_model_data where name='BAR_accountinvoice_form_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule';
4729+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_register_accountinginvoice_form_2_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule');
4730+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_invoice_open' where name='BAR_register_accountinginvoice_form_2_invoice_open' and module='sd';
4731+delete from msf_button_access_rights_button_access_rule where name='invoice_open' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_supplier_form_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule');
4732+delete from ir_model_data where name='BAR_accountinvoice_supplier_form_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule';
4733+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_supplier_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_register_accountinginvoice_supplier_form_2_invoice_open' and module='sd' and model='msf_button_access_rights.button_access_rule');
4734+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_supplier_form_invoice_open' where name='BAR_register_accountinginvoice_supplier_form_2_invoice_open' and module='sd';
4735+delete from msf_button_access_rights_button_access_rule where name='button_merge_lines' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_supplier_form_button_merge_lines' and module='sd' and model='msf_button_access_rights.button_access_rule');
4736+delete from ir_model_data where name='BAR_accountinvoice_supplier_form_button_merge_lines' and module='sd' and model='msf_button_access_rights.button_access_rule';
4737+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_supplier_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinvoice_supplier_form_3_button_merge_lines' and module='sd' and model='msf_button_access_rights.button_access_rule');
4738+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_supplier_form_button_merge_lines' where name='BAR_account_overrideinvoice_supplier_form_3_button_merge_lines' and module='sd';
4739+delete from msf_button_access_rights_button_access_rule where xmlname='account.action_account_invoice_refund' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_supplier_form_accountaction_account_invoice_refund' and module='sd' and model='msf_button_access_rights.button_access_rule');
4740+delete from ir_model_data where name='BAR_accountinvoice_supplier_form_accountaction_account_invoice_refund' and module='sd' and model='msf_button_access_rights.button_access_rule';
4741+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_supplier_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_register_accountinginvoice_supplier_form_2_accountaction_account_invoice_refund' and module='sd' and model='msf_button_access_rights.button_access_rule');
4742+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_supplier_form_accountaction_account_invoice_refund' where name='BAR_register_accountinginvoice_supplier_form_2_accountaction_account_invoice_refund' and module='sd';
4743+delete from msf_button_access_rights_button_access_rule where xmlname='account.action_account_invoice_refund' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_accountaction_account_invoice_refund' and module='sd' and model='msf_button_access_rights.button_access_rule');
4744+delete from ir_model_data where name='BAR_accountinvoice_form_accountaction_account_invoice_refund' and module='sd' and model='msf_button_access_rights.button_access_rule';
4745+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinherit_invoice_form_accountaction_account_invoice_refund' and module='sd' and model='msf_button_access_rights.button_access_rule');
4746+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_accountaction_account_invoice_refund' where name='BAR_account_overrideinherit_invoice_form_accountaction_account_invoice_refund' and module='sd';
4747+delete from msf_button_access_rights_button_access_rule where xmlname='account.account_invoices' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_accountaccount_invoices' and module='sd' and model='msf_button_access_rights.button_access_rule');
4748+delete from ir_model_data where name='BAR_accountinvoice_form_accountaccount_invoices' and module='sd' and model='msf_button_access_rights.button_access_rule';
4749+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinherit_invoice_form_accountaccount_invoices' and module='sd' and model='msf_button_access_rights.button_access_rule');
4750+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_accountaccount_invoices' where name='BAR_account_overrideinherit_invoice_form_accountaccount_invoices' and module='sd';
4751+delete from msf_button_access_rights_button_access_rule where name='wizard_import_si_line' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_wizard_import_si_line' and module='sd' and model='msf_button_access_rights.button_access_rule');
4752+delete from ir_model_data where name='BAR_accountinvoice_form_wizard_import_si_line' and module='sd' and model='msf_button_access_rights.button_access_rule';
4753+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinherit_invoice_form_wizard_import_si_line' and module='sd' and model='msf_button_access_rights.button_access_rule');
4754+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_wizard_import_si_line' where name='BAR_account_overrideinherit_invoice_form_wizard_import_si_line' and module='sd';
4755+delete from msf_button_access_rights_button_access_rule where name='wizard_import_si_line' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_supplier_form_wizard_import_si_line' and module='sd' and model='msf_button_access_rights.button_access_rule');
4756+delete from ir_model_data where name='BAR_accountinvoice_supplier_form_wizard_import_si_line' and module='sd' and model='msf_button_access_rights.button_access_rule';
4757+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_supplier_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_register_accountinginvoice_supplier_form_2_wizard_import_si_line' and module='sd' and model='msf_button_access_rights.button_access_rule');
4758+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_supplier_form_wizard_import_si_line' where name='BAR_register_accountinginvoice_supplier_form_2_wizard_import_si_line' and module='sd';
4759+delete from msf_button_access_rights_button_access_rule where name='invoice_open_with_confirmation' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_invoice_open_with_confirmation' and module='sd' and model='msf_button_access_rights.button_access_rule');
4760+delete from ir_model_data where name='BAR_accountinvoice_form_invoice_open_with_confirmation' and module='sd' and model='msf_button_access_rights.button_access_rule';
4761+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinherit_invoice_form_invoice_open_with_confirmation' and module='sd' and model='msf_button_access_rights.button_access_rule');
4762+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_invoice_open_with_confirmation' where name='BAR_account_overrideinherit_invoice_form_invoice_open_with_confirmation' and module='sd';
4763+delete from msf_button_access_rights_button_access_rule where name='invoice_open_with_sync_confirmation' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_invoice_open_with_sync_confirmation' and module='sd' and model='msf_button_access_rights.button_access_rule');
4764+delete from ir_model_data where name='BAR_accountinvoice_form_invoice_open_with_sync_confirmation' and module='sd' and model='msf_button_access_rights.button_access_rule';
4765+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinherit_invoice_form_invoice_open_with_sync_confirmation' and module='sd' and model='msf_button_access_rights.button_access_rule');
4766+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_invoice_open_with_sync_confirmation' where name='BAR_account_overrideinherit_invoice_form_invoice_open_with_sync_confirmation' and module='sd';
4767+delete from msf_button_access_rights_button_access_rule where name='import_invoice' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_import_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4768+delete from ir_model_data where name='BAR_accountinvoice_form_import_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule';
4769+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinherit_invoice_form_import_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4770+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_import_invoice' where name='BAR_account_overrideinherit_invoice_form_import_invoice' and module='sd';
4771+delete from msf_button_access_rights_button_access_rule where name='export_invoice' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_export_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4772+delete from ir_model_data where name='BAR_accountinvoice_form_export_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule';
4773+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinherit_invoice_form_export_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4774+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_export_invoice' where name='BAR_account_overrideinherit_invoice_form_export_invoice' and module='sd';
4775+delete from msf_button_access_rights_button_access_rule where name='invoice_cancel' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_invoice_cancel' and module='sd' and model='msf_button_access_rights.button_access_rule');
4776+delete from ir_model_data where name='BAR_accountinvoice_form_invoice_cancel' and module='sd' and model='msf_button_access_rights.button_access_rule';
4777+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinherit_invoice_form_invoice_cancel' and module='sd' and model='msf_button_access_rights.button_access_rule');
4778+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_invoice_cancel' where name='BAR_account_overrideinherit_invoice_form_invoice_cancel' and module='sd';
4779+delete from msf_button_access_rights_button_access_rule where name='button_split_invoice' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_form_button_split_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4780+delete from ir_model_data where name='BAR_accountinvoice_form_button_split_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule';
4781+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_overrideinherit_invoice_form_button_split_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4782+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_form_button_split_invoice' where name='BAR_account_overrideinherit_invoice_form_button_split_invoice' and module='sd';
4783+delete from msf_button_access_rights_button_access_rule where name='import_invoice' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_supplier_form_import_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4784+delete from ir_model_data where name='BAR_accountinvoice_supplier_form_import_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule';
4785+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_supplier_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_register_accountinginvoice_supplier_form_2_import_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4786+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_supplier_form_import_invoice' where name='BAR_register_accountinginvoice_supplier_form_2_import_invoice' and module='sd';
4787+delete from msf_button_access_rights_button_access_rule where name='export_invoice' and id in (select res_id from ir_model_data where name='BAR_accountinvoice_supplier_form_export_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4788+delete from ir_model_data where name='BAR_accountinvoice_supplier_form_export_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule';
4789+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='invoice_supplier_form' and module='account') where id in (select res_id from ir_model_data where name='BAR_register_accountinginvoice_supplier_form_2_export_invoice' and module='sd' and model='msf_button_access_rights.button_access_rule');
4790+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountinvoice_supplier_form_export_invoice' where name='BAR_register_accountinginvoice_supplier_form_2_export_invoice' and module='sd';
4791+delete from msf_button_access_rights_button_access_rule where name='button_corrections' and id in (select res_id from ir_model_data where name='BAR_accountview_account_analytic_line_tree_button_corrections' and module='sd' and model='msf_button_access_rights.button_access_rule');
4792+delete from ir_model_data where name='BAR_accountview_account_analytic_line_tree_button_corrections' and module='sd' and model='msf_button_access_rights.button_access_rule';
4793+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='view_account_analytic_line_tree' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_mcdbaccount_analytic_line_default_button_corrections' and module='sd' and model='msf_button_access_rights.button_access_rule');
4794+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountview_account_analytic_line_tree_button_corrections' where name='BAR_account_mcdbaccount_analytic_line_default_button_corrections' and module='sd';
4795+delete from msf_button_access_rights_button_access_rule where name='button_open_analytic_corrections' and id in (select res_id from ir_model_data where name='BAR_accountview_account_analytic_line_tree_button_open_analytic_corrections' and module='sd' and model='msf_button_access_rights.button_access_rule');
4796+delete from ir_model_data where name='BAR_accountview_account_analytic_line_tree_button_open_analytic_corrections' and module='sd' and model='msf_button_access_rights.button_access_rule';
4797+update msf_button_access_rights_button_access_rule set view_id=(select res_id from ir_model_data where model='ir.ui.view' and name='view_account_analytic_line_tree' and module='account') where id in (select res_id from ir_model_data where name='BAR_account_mcdbaccount_analytic_line_default_button_open_analytic_corrections' and module='sd' and model='msf_button_access_rights.button_access_rule');
4798+update ir_model_data set last_modification=NOW(), touched='[''name'']', name='BAR_accountview_account_analytic_line_tree_button_open_analytic_corrections' where name='BAR_account_mcdbaccount_analytic_line_default_button_open_analytic_corrections' and module='sd';
4799
4800=== modified file 'bin/addons/base/module/instance_auto_creation.py'
4801--- bin/addons/base/module/instance_auto_creation.py 2020-07-16 09:16:26 +0000
4802+++ bin/addons/base/module/instance_auto_creation.py 2021-11-03 13:33:55 +0000
4803@@ -486,6 +486,11 @@
4804 else:
4805 previous_fy_dates_allowed = False
4806
4807+ if config.has_option('reconfigure', 'customer_commitment'):
4808+ customer_commitment = config.getboolean('reconfigure', 'customer_commitment')
4809+ else:
4810+ customer_commitment = False
4811+
4812 if config.has_option('reconfigure', 'payroll_ok'):
4813 payroll_ok = config.getboolean('reconfigure', 'payroll_ok')
4814 else:
4815@@ -538,6 +543,9 @@
4816 },
4817 'previous.fy.dates.setup': {
4818 'previous_fy_dates_allowed': previous_fy_dates_allowed,
4819+ },
4820+ 'customer.commitment.setup': {
4821+ 'customer_commitment': customer_commitment,
4822 }
4823 }
4824 if country_id:
4825
4826=== modified file 'bin/addons/finance/account_analytic_line_view.xml'
4827--- bin/addons/finance/account_analytic_line_view.xml 2018-11-12 17:20:58 +0000
4828+++ bin/addons/finance/account_analytic_line_view.xml 2021-11-03 13:33:55 +0000
4829@@ -10,19 +10,34 @@
4830 <field name="priority" eval="10"/>
4831 <field name="arch" type="xml">
4832 <tree editable="top" noteditable="1" string="Analytic Journal Items" hide_delete_button="1" hide_new_button="1">
4833+ <field name="instance_id" readonly="1"/>
4834+ <field name="is_reversal" invisible="1"/>
4835+ <field name="journal_type" invisible="1"/>
4836+ <field name="is_corrigible" invisible="1"/>
4837+ <button name="button_corrections" type="object" string="Accounting info/correction"
4838+ attrs="{'invisible': [('is_corrigible', '=', False)]}" icon="terp-mail-message-new"/>
4839+ <field name="is_reallocated" invisible="1"/>
4840+ <field name="last_corrected_id" invisible="1"/>
4841+ <field name="is_engi" invisible="1"/>
4842+ <button string="Have been reallocated" attrs="{'invisible': [('is_reallocated', '=', False), ('last_corrected_id', '=', False)]}" icon="terp-mail-" colspan="2" name="button_open_analytic_corrections" type="object"/>
4843 <field name="journal_id" domain="[('is_current_instance','=',True)]"/>
4844- <field name="move_id"/>
4845+ <field name="entry_sequence"/>
4846 <field name="name"/>
4847 <field name="ref"/>
4848 <field name="document_date"/>
4849 <field name="date"/>
4850 <field name="period_id"/>
4851 <field name="general_account_id"/>
4852+ <field name="destination_id" string="Destination" invisible="not context.get('display_fp', False)"/>
4853+ <field name="cost_center_id" string="Cost Center" invisible="not context.get('display_fp', False)"/>
4854 <field name="account_id"/>
4855+ <field name="partner_txt"/>
4856 <field name="amount_currency" sum="Sum"/>
4857 <field name="currency_id"/>
4858 <field name="amount" sum="Sum"/>
4859 <field name="functional_currency_id"/>
4860+ <field name="output_amount"/>
4861+ <field name="output_currency"/>
4862 <field name="reversal_origin_txt"/>
4863 <field name="user_id" invisible="1"/>
4864 </tree>
4865
4866=== modified file 'bin/addons/finance/account_view.xml'
4867--- bin/addons/finance/account_view.xml 2019-06-18 11:15:45 +0000
4868+++ bin/addons/finance/account_view.xml 2021-11-03 13:33:55 +0000
4869@@ -2,25 +2,6 @@
4870 <openerp>
4871 <data>
4872
4873- <!-- Account View -->
4874- <record id="inherit_view_account_tree" model="ir.ui.view">
4875- <field name="name">inherit.view.account.tree</field>
4876- <field name="model">account.account</field>
4877- <field name="type">tree</field>
4878- <field name="field_parent">child_id</field>
4879- <field name="inherit_id" ref="account.view_account_tree"/>
4880- <field name="priority">19</field>
4881- <field name="arch" type="xml">
4882- <xpath expr="//field[@name='type']" position="replace">
4883- </xpath>
4884- <xpath expr="//field[@name='user_type']" position="after">
4885- <field name="type" invisible="1"/>
4886- <field name="type_for_register" invisible="1"/>
4887- <field name="accrual_account" invisible="1"/>
4888- </xpath>
4889- </field>
4890- </record>
4891-
4892 <!--
4893 Journal Entries
4894 -->
4895@@ -149,21 +130,6 @@
4896 <field name="context">{'from_web_menu': True}</field>
4897 </record>
4898
4899- <!-- Account View -->
4900- <record id="inherit_view_account_form" model="ir.ui.view">
4901- <field name='name'>inherit.view.account.form</field>
4902- <field name='model'>account.account</field>
4903- <field name="type">form</field>
4904- <field name="priority">50</field>
4905- <field name='inherit_id' ref='account.view_account_form' />
4906- <field name="arch" type="xml">
4907- <xpath expr="//field[@name='user_type']" position="after">
4908- <field name="shrink_entries_for_hq"/>
4909- <field name="is_child_of_coa" invisible="1" />
4910- <field name="display_in_reports" attrs="{'invisible': [('is_child_of_coa', '=', False)]}" />
4911- </xpath>
4912- </field>
4913- </record>
4914
4915 <!-- UF-1715 -->
4916 <report id="account_partner_balance_tree_xls"
4917
4918=== modified file 'bin/addons/finance/board_account_view.xml'
4919--- bin/addons/finance/board_account_view.xml 2021-08-25 14:50:30 +0000
4920+++ bin/addons/finance/board_account_view.xml 2021-11-03 13:33:55 +0000
4921@@ -64,7 +64,7 @@
4922 <field name="view_type">form</field>
4923 <field name="view_mode">tree,form,calendar,graph</field>
4924 <!-- US-2704 domain is related to action_account_commitment_tree of analytic_distribution/account_commitment_view.xml with state='draft' domain addition -->
4925- <field name="domain">[('state', '=', 'draft')]</field>
4926+ <field name="domain">[('state', '=', 'draft'), ('cv_flow_type', '=', 'supplier')]</field>
4927 <field name="context">{'board_view': True, 'search_default_draft': 1}</field>
4928 <field ref="account_board_commitment_voucher_view" name="view_id"/>
4929 <field name="limit">5</field>
4930@@ -96,8 +96,8 @@
4931 <field name="view_type">form</field>
4932 <field name="view_mode">tree,form,calendar,graph</field>
4933 <!-- US-2704 domain is related to account.action_invoice_tree2 of account_override/account_invoice_view.xml with state='draft' domain addition -->
4934- <field name="domain">[('state', '=', 'draft'), ('type','=','in_invoice'), ('is_direct_invoice', '=', False), ('is_inkind_donation', '=', False), ('is_debit_note', "=", False), ('is_intermission', '=', False)]</field>
4935- <field name="context">{'board_view': True, 'type': 'in_invoice', 'search_default_draft': 1}</field>
4936+ <field name="domain">[('state', '=', 'draft'), ('doc_type', '=', 'si')]</field>
4937+ <field name="context">{'doc_type': 'si', 'board_view': True, 'type': 'in_invoice', 'journal_type': 'purchase', 'from_inv_form': True, 'search_default_draft': 1}</field>
4938 <field ref="account_board_supplier_invoice_draft_view" name="view_id"/>
4939 <field name="limit">5</field>
4940 </record>
4941@@ -108,8 +108,8 @@
4942 <field name="view_type">form</field>
4943 <field name="view_mode">tree,form,calendar,graph</field>
4944 <!-- US-2704 domain is related to account.action_invoice_tree2 of account_override/account_invoice_view.xml with state='open' domain addition -->
4945- <field name="domain">[('state', '=', 'open'), ('type','=','in_invoice'), ('is_direct_invoice', '=', False), ('is_inkind_donation', '=', False), ('is_debit_note', "=", False), ('is_intermission', '=', False)]</field>
4946- <field name="context">{'board_view': True, 'type': 'in_invoice', 'search_default_unpaid': 1}</field>
4947+ <field name="domain">[('state', '=', 'open'), ('doc_type', '=', 'si')]</field>
4948+ <field name="context">{'doc_type': 'si', 'board_view': True, 'type': 'in_invoice', 'journal_type': 'purchase', 'from_inv_form': True, 'search_default_unpaid': 1}</field>
4949 <field ref="account_board_supplier_invoice_draft_view" name="view_id"/>
4950 <field name="limit">5</field>
4951 </record>
4952
4953=== modified file 'bin/addons/msf_accrual/__openerp__.py'
4954--- bin/addons/msf_accrual/__openerp__.py 2017-10-09 21:06:10 +0000
4955+++ bin/addons/msf_accrual/__openerp__.py 2021-11-03 13:33:55 +0000
4956@@ -31,7 +31,6 @@
4957 "update_xml": [
4958 'security/ir.model.access.csv',
4959 'msf_accrual_view.xml',
4960- 'account_view.xml',
4961 'wizard/wizard_accrual_view.xml',
4962 'wizard/wizard_accrual_reversal_view.xml'
4963 ],
4964
4965=== removed file 'bin/addons/msf_accrual/account_view.xml'
4966=== modified file 'bin/addons/msf_currency_revaluation/__openerp__.py'
4967--- bin/addons/msf_currency_revaluation/__openerp__.py 2019-11-04 10:48:48 +0000
4968+++ bin/addons/msf_currency_revaluation/__openerp__.py 2021-11-03 13:33:55 +0000
4969@@ -59,7 +59,6 @@
4970 "account",
4971 ],
4972 "init_xml": [
4973- "account_view.xml",
4974 "wizard/wizard_currency_revaluation_view.xml"],
4975 "update_xml": [],
4976 "demo_xml": [],
4977
4978=== removed file 'bin/addons/msf_currency_revaluation/account_view.xml'
4979=== modified file 'bin/addons/msf_doc_import/wizard/wizard_import_invoice_line.py'
4980--- bin/addons/msf_doc_import/wizard/wizard_import_invoice_line.py 2019-10-30 16:33:21 +0000
4981+++ bin/addons/msf_doc_import/wizard/wizard_import_invoice_line.py 2021-11-03 13:33:55 +0000
4982@@ -373,105 +373,6 @@
4983 self.write(cr, uid, ids, {'message': _(' Import in progress... \n Please wait that the import is finished before editing %s.') % (invoice_name or _('the object'), )})
4984 return False
4985
4986- def get_invoice_view(self, cr, uid, invoice_id, view_name, domain, context=None):
4987- if view_name in ('view_intermission_form'):
4988- module = 'account_override'
4989- else:
4990- module = 'account'
4991- if view_name:
4992- view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, module, view_name)
4993- view_id = view_id and view_id[1] or False
4994- tree_view = self.pool.get('ir.model.data').get_object_reference(cr,
4995- uid, 'account', 'invoice_tree')
4996- tree_view_id = tree_view and tree_view[1] or False
4997- return {
4998- 'type': 'ir.actions.act_window',
4999- 'res_model': 'account.invoice',
5000- 'view_type': 'form',
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches