Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
92 changes: 92 additions & 0 deletions account_invoice_purchase_picking_selection/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
==============================================
Autocomplete purchase invoices from receptions
==============================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:622e17d9ae10d521496c54ff6f310cb6f7fe675c6c2a6eb44e727fb379c85849
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
:target: https://github.com/OCA/account-invoicing/tree/14.0/account_invoice_purchase_picking_selection
:alt: OCA/account-invoicing
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-invoicing-14-0/account-invoicing-14-0-account_invoice_purchase_picking_selection
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Autocomplete invoices lines by selecting the receptions originating from a purchase order.

**Table of contents**

.. contents::
:local:

Usage
=====

- Create some storable products and set the `Control Policy` to `On received quantities`.
- Create a purchase order with the previously created storable products.
- Confirm the purchase order
- Receive the products
- Go to `Invoicing > Vendors > Bills`
- Create a new bill
- Select the picking in the `Auto-Complete from Picking` field
- The invoice lines will be automatically filled with the product quantities from the picking.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_purchase_picking_selection%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_

* Pedro M. Baeza
* Carlos Lopez


Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/14.0/account_invoice_purchase_picking_selection>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions account_invoice_purchase_picking_selection/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions account_invoice_purchase_picking_selection/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Autocomplete purchase invoices from receptions",
"version": "14.0.1.0.0",
"summary": "Autocomplete invoices lines "
"by selecting the receptions originating from a purchase order.",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-invoicing",
"category": "Inventory/Purchase",
"depends": [
"purchase_stock",
],
"data": ["views/account_move_views.xml"],
"installable": True,
"license": "AGPL-3",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_purchase_picking_selection
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-19 15:27+0000\n"
"PO-Revision-Date: 2025-03-19 15:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_invoice_purchase_picking_selection
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_bank_statement_line__autocomplete_purchase_picking_id
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move__autocomplete_purchase_picking_id
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_payment__autocomplete_purchase_picking_id
msgid "Auto-Complete from Picking"
msgstr ""

#. module: account_invoice_purchase_picking_selection
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move__display_name
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_stock_picking__display_name
msgid "Display Name"
msgstr ""

#. module: account_invoice_purchase_picking_selection
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move__id
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move_line__id
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_stock_picking__id
msgid "ID"
msgstr ""

#. module: account_invoice_purchase_picking_selection
#: model:ir.model,name:account_invoice_purchase_picking_selection.model_account_move
msgid "Journal Entry"
msgstr ""

#. module: account_invoice_purchase_picking_selection
#: model:ir.model,name:account_invoice_purchase_picking_selection.model_account_move_line
msgid "Journal Item"
msgstr ""

#. module: account_invoice_purchase_picking_selection
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move____last_update
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_stock_picking____last_update
msgid "Last Modified on"
msgstr ""

#. module: account_invoice_purchase_picking_selection
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move_line__picking_invoiced_id
msgid "Picking"
msgstr ""

#. module: account_invoice_purchase_picking_selection
#: model_terms:ir.ui.view,arch_db:account_invoice_purchase_picking_selection.view_account_move_form
msgid "Select a purchase reception"
msgstr ""

#. module: account_invoice_purchase_picking_selection
#: model:ir.model,name:account_invoice_purchase_picking_selection.model_stock_picking
msgid "Transfer"
msgstr ""
71 changes: 71 additions & 0 deletions account_invoice_purchase_picking_selection/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_purchase_picking_selection
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-19 15:27+0000\n"
"PO-Revision-Date: 2025-03-19 10:28-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.5\n"

#. module: account_invoice_purchase_picking_selection
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_bank_statement_line__autocomplete_purchase_picking_id
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move__autocomplete_purchase_picking_id
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_payment__autocomplete_purchase_picking_id
msgid "Auto-Complete from Picking"
msgstr "Completar automáticamente desde albarán"

#. module: account_invoice_purchase_picking_selection
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move__display_name
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_stock_picking__display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: account_invoice_purchase_picking_selection
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move__id
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move_line__id
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_stock_picking__id
msgid "ID"
msgstr ""

#. module: account_invoice_purchase_picking_selection
#: model:ir.model,name:account_invoice_purchase_picking_selection.model_account_move
msgid "Journal Entry"
msgstr "Asiento contable"

#. module: account_invoice_purchase_picking_selection
#: model:ir.model,name:account_invoice_purchase_picking_selection.model_account_move_line
msgid "Journal Item"
msgstr "Apunte contable"

#. module: account_invoice_purchase_picking_selection
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move____last_update
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_stock_picking____last_update
msgid "Last Modified on"
msgstr "Última modificación el"

#. module: account_invoice_purchase_picking_selection
#: model:ir.model.fields,field_description:account_invoice_purchase_picking_selection.field_account_move_line__picking_invoiced_id
msgid "Picking"
msgstr "Albarán"

#. module: account_invoice_purchase_picking_selection
#: model_terms:ir.ui.view,arch_db:account_invoice_purchase_picking_selection.view_account_move_form
msgid "Select a purchase reception"
msgstr "Seleccione una recepción de compra"

#. module: account_invoice_purchase_picking_selection
#: model:ir.model,name:account_invoice_purchase_picking_selection.model_stock_picking
msgid "Transfer"
msgstr "Albarán"
3 changes: 3 additions & 0 deletions account_invoice_purchase_picking_selection/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import account_move
from . import stock_picking
from . import stock_move
77 changes: 77 additions & 0 deletions account_invoice_purchase_picking_selection/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from odoo import api, fields, models
from odoo.tools.float_utils import float_is_zero


class AccountMove(models.Model):
_inherit = "account.move"

autocomplete_purchase_picking_id = fields.Many2one(
"stock.picking", copy=False, string="Auto-Complete from Picking"
)

@api.onchange("autocomplete_purchase_picking_id")
def _onchange_autocomplete_purchase_picking_id(self):
"""Load from either an stock.picking."""
if (
not self.autocomplete_purchase_picking_id
or not self.autocomplete_purchase_picking_id.purchase_id
):
return

# Copy data from PO
purchase = self.autocomplete_purchase_picking_id.purchase_id
stock_moves = self.autocomplete_purchase_picking_id.move_lines
invoice_vals = purchase.with_company(purchase.company_id)._prepare_invoice()
invoice_vals["currency_id"] = (
self.line_ids and self.currency_id or invoice_vals.get("currency_id")
)
del invoice_vals["ref"]
self.update(invoice_vals)

# Copy purchase lines.
stock_moves -= self.line_ids.mapped("stock_move_invoiced_id")
new_lines = self.env["account.move.line"]
sequence = max(self.line_ids.mapped("sequence")) + 1 if self.line_ids else 10
precision = self.env["decimal.precision"].precision_get(
"Product Unit of Measure"
)
for stock_move in stock_moves:
if float_is_zero(
stock_move.qty_received_to_invoice, precision_digits=precision
):
continue

Check warning on line 42 in account_invoice_purchase_picking_selection/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_invoice_purchase_picking_selection/models/account_move.py#L42

Added line #L42 was not covered by tests
line_vals = stock_move._prepare_account_move_line_from_stock(self, sequence)
new_line = new_lines.new(line_vals)
sequence += 1
new_line.account_id = new_line._get_computed_account()
new_line._onchange_price_subtotal()
new_lines += new_line
new_lines._onchange_mark_recompute_taxes()
new_lines.picking_invoiced_id = self.autocomplete_purchase_picking_id

# Compute invoice_origin.
origins = set(self.line_ids.mapped("purchase_line_id.order_id.name"))
self.invoice_origin = ",".join(list(origins))

# Compute ref.
refs = self._get_invoice_reference()
self.ref = ", ".join(refs)

# Compute payment_reference.
if len(refs) == 1:
self.payment_reference = refs[0]

self.autocomplete_purchase_picking_id = False
self.purchase_id = False
self._onchange_currency()


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

stock_move_invoiced_id = fields.Many2one(
"stock.move", string="Stock Move", copy=False, readonly=True
)
picking_invoiced_id = fields.Many2one(
"stock.picking", string="Picking", copy=False, readonly=True
)
Loading