Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][MIG] stock_picking_invoicing: Migration to 15.0 #1452

Merged
merged 123 commits into from
May 20, 2023
Merged
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
af34ef3
[REF] Renaming module stock_invoice_picking -> stock_picking_invoicing
mileo Jun 21, 2015
f5c939c
Fix module name in README
tafaRU Jun 23, 2015
4f0809c
Add Bug Tracker to README
tafaRU Jun 23, 2015
b8404b0
[FIX] stock_picking_invoicing: README
pedrobaeza Jun 23, 2015
aa4dcb8
[FIX] wrong bug tracker link
eLBati Jun 23, 2015
2e0cd9e
[FIX] using wrong partner for invoice, when delivering to a company a…
eLBati Jul 7, 2015
98563da
OCA Transbot updated translations from Transifex
oca-transbot Sep 1, 2015
ea61d68
OCA Transbot updated translations from Transifex
oca-transbot Sep 13, 2015
359e1e7
[UPD] prefix versions with 8.0
sbidoul Oct 9, 2015
18102be
[MIG] Make modules uninstallable
pedrobaeza Oct 14, 2015
9e2d6ec
[FIX] remove en.po that was erroneously created by transbot
sbidoul Aug 15, 2016
6ff560b
[MIG] Rename manifest files
pedrobaeza Oct 6, 2016
afaaa18
Initiate the migration
flotho Mar 19, 2016
0902318
Add the fields on the object and views
flotho Mar 19, 2016
63c7d96
Implements the mechanics of views :
flotho Mar 20, 2016
61b572f
Views Improvements
flotho Mar 20, 2016
b2e9f98
Business logic Ok :
flotho Mar 20, 2016
efa2b7d
Finalise business part :
flotho Mar 20, 2016
9eea32f
Correction of bad Class usage
flotho Mar 20, 2016
4ae9296
Add intercompany workflow
flotho Mar 21, 2016
de354f1
better management of list_price
flotho Mar 21, 2016
0947118
OCA guidelines
flotho Apr 1, 2016
4137ff1
OCA guidelines
flotho Apr 1, 2016
c282ea9
Add dependencies and correct library from Travis
flotho Apr 1, 2016
2261956
Correct library from Travis
flotho Apr 1, 2016
781262b
Correction https://travis-ci.org/OCA/account-invoicing/jobs/120042968
flotho Apr 1, 2016
3676108
Add an option for forcing the invoice status in the wizard
flotho Apr 15, 2016
36788b0
Comment unreachable part of the code
flotho May 13, 2016
77ffc61
Change test parts
flotho May 13, 2016
05b7d94
[FIX]Context values missing
flotho May 22, 2016
dbe124b
[FIX][TEST]set mandatory fields
flotho May 22, 2016
a92a3d8
[10.0][MIG] Add stock_picking_invoicing (from existing open MR in 9.0)
acsonefho Feb 27, 2019
ccf804e
[UPD] Update stock_picking_invoicing.pot
oca-travis Jul 11, 2019
d67fd98
[UPD] README.rst
OCA-git-bot Jul 11, 2019
d215d2d
[UPD] Update stock_picking_invoicing.pot
oca-travis Jul 11, 2019
d0eb212
[MIG] stock_picking_invoicing: Migration to 12.0, changed version and…
mbcosta Jul 15, 2019
71b6b16
[MIG] stock_picking_invoicing: Migration to 12.0, views.
mbcosta Jul 16, 2019
7cc7159
[MIG] stock_picking_invoicing: Migration to 12.0, tests.
mbcosta Jul 16, 2019
9f2bd08
[12.0][MIG][FIX] The journal type refund was removed since version 10…
mbcosta Dec 16, 2019
2c2247e
[12.0][MIG][REF] Included dependency of module stock_picking_invoice_…
mbcosta Dec 19, 2019
9125afe
[12.0][MIG][IMP] Tests, creation of invoice lines based on stock.move .
mbcosta Dec 20, 2019
6223de7
[12.0][MIG][IMP] Included in kanban view pickings with invoice_state …
mbcosta Dec 20, 2019
c1edc2f
[12.0][MIG][FIX] Button set_to_be_invoice was missing.
mbcosta Jan 10, 2020
7088af9
[12.0][MIG][FIX] Position of field in the view.
mbcosta Jan 10, 2020
bf5bb91
[12.0][MIG][IMP] Demo data.
mbcosta Jan 10, 2020
37daf6e
[12.0][MIG][FIX] README.
mbcosta Jan 13, 2020
2558de3
[12.0][MIG][FIX] PEP8.
mbcosta Jan 13, 2020
bf1400a
[NEW] Ungroup picking
mileo Jan 13, 2020
6d4c422
[IMP] Improve invoice create perfomance
mileo Jan 5, 2020
3e42205
[MOV] _update_picking_invoice_status to allow queue_job calls
mileo Jan 5, 2020
cd3e167
[FIX] ungroup moves
mileo Jan 13, 2020
e968d40
[12.0][MIG][IMP] Tests.
mbcosta Jan 14, 2020
8872522
[12.0][MIG][IMP] Demo data.
mbcosta Jan 27, 2020
492b8be
[12.0][MIG][IMP] When there is only 1 invoice (the usual case) open t…
mbcosta Jan 27, 2020
7682c9f
[12.0][MIG][FIX] Determine type of tax based on journal type, fields …
mbcosta Jan 31, 2020
5ced4b7
[12.0][MIG][IMP] Tests, check if there are taxes in created invoice.
mbcosta Jan 31, 2020
d0c5c5d
[FIX] Invoice taxes
mileo Feb 19, 2020
b535872
[12.0][MIG][FIX] Removed unnecessary pre_init_hook.
mbcosta Feb 20, 2020
aca919b
[12.0][MIG[FIX] Name view to keep standard.
mbcosta Apr 15, 2020
44f1f88
[12.0][MIG[FIX] Field invoice_line_id many2one change to invoice_line…
mbcosta Apr 15, 2020
80ef59c
[UPD] Update stock_picking_invoicing.pot
oca-travis Apr 24, 2020
8230ceb
[UPD] README.rst
OCA-git-bot Apr 24, 2020
500af7c
Update translation files
oca-transbot Apr 27, 2020
99fb536
[IMP] set name and uom from moves instead of product
sergiocorato Apr 28, 2020
fd4d295
Added translation using Weblate (Portuguese (Brazil))
marcelsavegnago Jun 2, 2020
ac1044f
Translated using Weblate (Portuguese (Brazil))
fcolus Jun 5, 2020
7e17845
[UPD] Update stock_picking_invoicing.pot
oca-travis Jun 12, 2020
8a30ad0
stock_picking_invoicing 12.0.2.0.1
OCA-git-bot Jun 12, 2020
5bc2f57
Update translation files
oca-transbot Jun 12, 2020
3d8834a
[UPD] Update stock_picking_invoicing.pot
oca-travis Jun 12, 2020
60e573f
Update translation files
oca-transbot Jun 12, 2020
66334cf
Added translation using Weblate (German)
marylla Jun 12, 2020
e5e18b0
Added translation using Weblate (Spanish)
Jun 20, 2020
90afcce
Translated using Weblate (Spanish)
Jun 20, 2020
b6ed5e9
Translated using Weblate (Slovenian)
sysadminmatmoz Aug 11, 2020
1b140fc
[FIX] account.journal type values in wizard's constant
renatonlima Aug 13, 2020
db0c714
Update translation files
oca-transbot Aug 16, 2020
dd27d92
[IMP] stock_picking_invoicing: black, isort, prettier
Rad0van Dec 18, 2020
41fb55a
[MIG] stock_picking_invoicing: Migration to 13.0
Rad0van Dec 18, 2020
86dd578
[FIX] sale_line_ids value
marcelsavegnago Jan 30, 2021
dbc2512
stock_picking_invoicing 13.0.2.1.0
OCA-git-bot Jan 30, 2021
48834eb
stock_picking_invoicing 13.0.2.1.1
OCA-git-bot Jan 30, 2021
ac08077
[FIX] wrong invoice price_unit
renatonlima Feb 3, 2021
c81d1a1
stock_picking_invoicing 13.0.2.1.2
OCA-git-bot Feb 9, 2021
cdd948c
[REM] Relation with purchase_id, purchase_line_id and sale_line_id wi…
mbcosta Feb 8, 2021
46c8856
stock_picking_invoicing 13.0.2.1.3
OCA-git-bot Feb 10, 2021
f612f9d
[FIX] Pickings with same Partner to create Invoice but the Partner to…
mbcosta Feb 12, 2021
fd9321c
stock_picking_invoicing 13.0.2.1.4
OCA-git-bot Feb 15, 2021
a1f3675
Copy invoice state in backorders and extra stock move in pickings
renatonlima Mar 19, 2021
500873c
stock_picking_invoicing 13.0.2.2.0
OCA-git-bot Mar 19, 2021
314188a
[IMP] Option to Invoicing Return Picking in wizard.
mbcosta Mar 23, 2021
176c991
[FIX] Invoice Type mapping.
mbcosta Mar 23, 2021
7cffba6
[IMP] Included test Return Picking Invoicing and Invoice created and …
mbcosta Mar 23, 2021
13192a0
stock_picking_invoicing 13.0.3.0.0
OCA-git-bot Mar 24, 2021
5d2c8cb
[FIX] Invoice Type mapping.
mbcosta Mar 24, 2021
745b74c
stock_picking_invoicing 13.0.3.1.0
OCA-git-bot Mar 24, 2021
e6f8258
[IMP] stock_picking_invoicing: add action_invoice_draft method
marcelsavegnago Jul 12, 2021
2b426ed
[REF] Removed unnecessary api.multi and parameter to call super.
mbcosta Oct 4, 2021
cd865bb
[MIG] Action 'Create Draft Invoice'.
mbcosta Oct 4, 2021
87f2291
[FIX] Pre-commit.
mbcosta Oct 4, 2021
e17393b
[MIG] Method action_invoice_draft became button_draft.
mbcosta Oct 5, 2021
8b38baf
[MIG] Object account.invoice was merged in account.move .
mbcosta Oct 5, 2021
65b88c4
[MIG] Method don't exist anymore and work without it.
mbcosta Oct 5, 2021
079f8d0
[UPD] Update stock_picking_invoicing.pot
oca-travis Oct 5, 2021
7ce0f60
[UPD] README.rst
OCA-git-bot Oct 5, 2021
370fb47
[MIG] stock_picking_invoicing: Migration to 14.0
rvalyi Oct 5, 2021
642b6b9
[MIG][stock_picking_invoicing][REF] Stock Move view
mileo Oct 21, 2020
2dce4a2
[MIG] stock_picking_invoicing: Migration to 14.0
Zar21 Oct 4, 2021
65a47c3
[FIX] Always return tuple to avoid need to check it in the inherits m…
mbcosta Oct 19, 2021
b4fe961
[REM] Unnecessary parameters to call super.
mbcosta Oct 19, 2021
90341d0
[FIX] English comments.
mbcosta Nov 5, 2021
6d3d6af
[UPD] Update HISTORY.rst.
mbcosta Nov 12, 2021
1a0c04a
[UPD] Update stock_picking_invoicing.pot
oca-travis Nov 12, 2021
8fa735e
[UPD] README.rst
OCA-git-bot Nov 12, 2021
de40a81
[FIX] s_p_invoicing: fix access right issues when using actions
sebalix Jan 31, 2022
f90060d
stock_picking_invoicing 14.0.1.0.1
OCA-git-bot Feb 2, 2022
bce4875
Added translation using Weblate (Catalan)
extrememicro Feb 9, 2022
5ccbd33
[FIX][BUG] Get the current company should be made with self.env.company
mbcosta Feb 16, 2022
f57d216
stock_picking_invoicing 14.0.1.0.2
OCA-git-bot Feb 16, 2022
232136c
[FIX] stock_picking_invoicing: Avoid W7940 (dangerous-view-replace-wo…
pedrobaeza Mar 30, 2022
b14e7e7
Translated using Weblate (Portuguese (Brazil))
douglascstd Aug 12, 2022
9dd6a59
[MIG] stock_picking_invoicing: Migration to 15.0
mbcosta Apr 28, 2023
76f2c30
[REF] stock_picking_invoicing: Removed unnecessary fields at the crea…
mbcosta May 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[FIX]Context values missing
[IMP]Add the availability to choose the company that will invoice
  • Loading branch information
flotho authored and mbcosta committed May 19, 2023
commit 05b7d943b72f49bd41f3b21dc9f2fd974b77670e
2 changes: 1 addition & 1 deletion stock_picking_invoicing/models/__init__.py
Original file line number Diff line number Diff line change
@@ -3,4 +3,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import stock
from . import invoice
from . import account_invoice
File renamed without changes.
20 changes: 13 additions & 7 deletions stock_picking_invoicing/models/stock.py
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ def _get_master_data(self, move, company):
def _get_taxes(self, fiscal_position):
self.ensure_one()
taxes_ids = self.product_id.taxes_id
my_taxes = taxes_ids.filtered(lambda r: r.company_id.id == self.company_id.id)
my_taxes = taxes_ids.filtered(lambda r: r.company_id.id == self.env.context['force_company'])
my_taxes = fiscal_position.map_tax(my_taxes)
my_taxes = [t.id for t in my_taxes]

@@ -274,6 +274,7 @@ def _create_invoice_from_picking(self, picking, vals):
''' This function simply creates the invoice from the given values. It is overriden in delivery module to add the delivery costs.
'''
invoice_obj = self.env['account.invoice']
_logger.debug("Create invoice with %s" % vals)
return invoice_obj.create(vals)

@api.model
@@ -319,21 +320,24 @@ def _invoice_create_line(self, moves, journal_id, inv_type='out_invoice'):

is_extra_move, extra_move_tax = move_obj._get_moves_taxes(moves, inv_type)
product_price_unit = {}

_logger.debug("COntexte %s" % self.env.context)
invoice_id = None
company_id = self.env.context['force_company'] or self.env['res.users']._get_company()
for move in moves:
company = move.company_id
origin = move.picking_id.name
company = self.env['res.company'].search([('id', '=', company_id)])
origin = move.sudo().picking_id.name
partner, user_id, currency_id = move_obj._get_master_data(move, company)
key = (partner, currency_id, company.id, user_id)

_logger.debug("contexte %s" % self.env.context)
invoice_vals = self._get_invoice_vals(key, inv_type, journal_id, move)
if key not in invoices:
# Get account and payment terms
_logger.debug("Add invoice to list")
invoice_id = self._create_invoice_from_picking(move.picking_id, invoice_vals)
invoices[key] = invoice_id.id

_logger.debug("Add invoice to list after key")
else:
_logger.debug("Add found invoice to list")
invoice = invoice_obj.search([('id', '=', invoices[key])])
merge_vals = {}
if not invoice.origin or invoice_vals['origin'] not in invoice.origin.split(', '):
@@ -344,10 +348,11 @@ def _invoice_create_line(self, moves, journal_id, inv_type='out_invoice'):
invoice_name = filter(None, [invoice.name, invoice_vals['name']])
merge_vals['name'] = ', '.join(invoice_name)
if merge_vals:
_logger.debug("Merge vues %s" % merge_vals)
invoice.write(merge_vals)

move.with_context(
fp_id=invoice_vals.get('fiscal_position_id', False)
fp_id=invoice_vals.get('fiscal_position_id', False),
)

invoice_line_vals = move._get_invoice_line_vals(partner, inv_type)
@@ -368,6 +373,7 @@ def _invoice_create_line(self, moves, journal_id, inv_type='out_invoice'):
invoice_line_vals['invoice_line_tax_id'] = extra_move_tax[0, move.product_id]

invoice_line = move._create_invoice_line_from_vals(invoice_line_vals)
_logger.debug("Before invoicing write")
if invoice_line :
move.write({'invoice_line_id': invoice_line.id,
'invoice_state': 'invoiced'
2 changes: 1 addition & 1 deletion stock_picking_invoicing/views/stock_view.xml
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|',('state','&lt;&gt;','done'),('invoice_state','&lt;&gt;','2binvoiced')]}" type="action" class="oe_highlight" groups="base.group_user"/>
</xpath>
<field name="move_lines" position="attributes">
<attribute name="context">{'default_invoice_state': invoice_state, 'address_in_id': partner_id, 'form_view_ref':'stock.view_move_picking_form', 'tree_view_ref':'stock.view_move_picking_tree', 'default_picking_type_id': picking_type_id,'default_picking_id': active_id}</attribute>
<attribute name="context">{'default_invoice_state': invoice_state, 'address_in_id': partner_id, 'form_view_ref':'stock.view_move_picking_form', 'tree_view_ref':'stock.view_move_picking_tree', 'default_picking_type_id': picking_type_id,'default_picking_id': active_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}</attribute>
</field>
<xpath expr="//field[@name='move_type']" position="after">
<field name="invoice_state" groups="account.group_account_invoice"/>
51 changes: 29 additions & 22 deletions stock_picking_invoicing/wizard/stock_invoice_onshipping.py
Original file line number Diff line number Diff line change
@@ -110,12 +110,14 @@ def _get_journal_type(self):
context = self.env.context or {}
res_ids = context and context.get('active_ids', [])
pick_obj = self.env['stock.picking']
pickings = pick_obj.search([('id', 'in', res_ids)])
pick = pickings and pickings[0]
if not pick or not pick.move_lines:
pickings = pick_obj.sudo().search([('id', 'in', res_ids)])
pick = pickings and pickings[0]
if not pick or not pick.sudo().move_lines:
return 'sale'
type = pick.picking_type_id.code
usage = pick.move_lines[0].location_id.usage if type == 'incoming' else pick.move_lines[0].location_dest_id.usage
type = pick.sudo().picking_type_id.code
usage = pick.sudo().move_lines[0].location_id.usage \
if type == 'incoming' \
else pick.sudo().move_lines[0].location_dest_id.usage

return JOURNAL_TYPE_MAP.get((type, usage), ['sale'])[0]

@@ -156,7 +158,10 @@ def _get_journal_type(self):
show_purchase_journal = fields.Boolean(string="Show Purchase Journal")
show_purchase_refund_journal = fields.Boolean(
string="Show Refund Purchase Journal")


company_id = fields.Many2one(comodel_name="res.company",
string='Company to invoice',
default=lambda self:self.env.user.company_id.id)

#=================
# Business part
@@ -207,10 +212,11 @@ def create_invoice(self):
pickings = self.env['stock.picking'].search([('id', 'in', active_ids)])
pickings.set_invoiced()


self = self.with_context(
force_company_id = self.company_id.id or self.env['res.users']._get_company()
picking_pool = picking_pool.with_context(
date_inv = self.invoice_date,
inv_type = inv_type
inv_type = inv_type,
force_company=force_company_id
)

res = picking_pool.action_invoice_create(active_ids,
@@ -258,14 +264,14 @@ def create_invoice(self):
def get_partner_sum(self, pickings, partner, inv_type, picking_type,
usage):
move_obj = self.env['stock.move']
pickings = pickings.filtered(lambda x: x.picking_type_id.code ==
pickings = pickings.filtered(lambda x: x.sudo().picking_type_id.code ==
picking_type and x.partner_id == partner)
if picking_type == 'outgoing':
moves = pickings.mapped('move_lines').filtered(
lambda x: x.location_dest_id.usage == usage)
moves = pickings.sudo().mapped('move_lines').filtered(
lambda x: x.sudo().location_dest_id.usage == usage)
else:
moves = pickings.mapped('move_lines').filtered(
lambda x: x.location_id.usage == usage)
moves = pickings.sudo().mapped('move_lines').filtered(
lambda x: x.sudo().location_id.usage == usage)
return (sum([(m._get_price_unit_invoice( inv_type) *
m.product_uom_qty) for m in moves]),
moves.mapped('picking_id'))
@@ -300,18 +306,19 @@ def get_split_pickings_grouped(self, pickings):
@api.multi
def get_split_pickings_nogrouped(self, pickings):
sale_pickings = pickings.filtered(
lambda x: x.picking_type_id.code == 'outgoing' and
x.move_lines[:1].location_dest_id.usage == 'customer')
lambda x: x.sudo().picking_type_id.code == 'outgoing' and
x.sudo().move_lines[:1].location_dest_id.usage == 'customer')
# use [:1] instead of [0] to avoid a errors on empty pickings
sale_refund_pickings = pickings.filtered(
lambda x: x.picking_type_id.code == 'incoming' and
x.move_lines[:1].location_id.usage == 'customer')
lambda x: x.sudo().picking_type_id.code == 'incoming' and
x.sudo().move_lines[:1].location_id.usage == 'customer')
purchase_pickings = pickings.filtered(
lambda x: x.picking_type_id.code == 'incoming' and
x.move_lines[:1].location_id.usage == 'supplier')
lambda x: x.sudo().picking_type_id.code == 'incoming' and
x.sudo().move_lines[:1].location_id.usage == 'supplier')
purchase_refund_pickings = pickings.filtered(
lambda x: x.picking_type_id.code == 'outgoing' and
x.move_lines[:1].location_dest_id.usage == 'supplier')
lambda x: x.sudo().picking_type_id.code == 'outgoing' and
x.sudo().move_lines[:1].location_dest_id.usage == 'supplier')

return (sale_pickings, sale_refund_pickings, purchase_pickings,
purchase_refund_pickings)

Original file line number Diff line number Diff line change
@@ -22,9 +22,11 @@
<field name="sale_refund_journal" attrs="{'invisible':[('show_sale_refund_journal', '=', False)], 'required':[('show_sale_refund_journal', '=', True)]}"/>
<field name="purchase_journal" attrs="{'invisible':[('show_purchase_journal', '=', False)], 'required':[('show_purchase_journal', '=', True)]}"/>
<field name="purchase_refund_journal" domain="[('type', '=', 'purchase_refund')]" attrs="{'invisible':[('show_purchase_refund_journal', '=', False)], 'required':[('show_purchase_refund_journal', '=', True)]}"/>
<field name="company_id" invisible="0" required="1"/>
<field name="group"/>
<field name="invoice_date" />
<field name="invoice_force" />

</group>
<footer>
<button name="open_invoice" string="Create" type="object" class="oe_highlight"/>