Skip to content

Commit

Permalink
[ADD] Module sale_stock_picking_invoicing, based in https://github.co…
Browse files Browse the repository at this point in the history
  • Loading branch information
mbcosta committed Nov 12, 2021
1 parent 36e1e91 commit 27e6185
Show file tree
Hide file tree
Showing 28 changed files with 1,604 additions and 0 deletions.
124 changes: 124 additions & 0 deletions sale_stock_picking_invoicing/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
============================
Sales Stock Picking Invocing
============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
:target: https://github.com/OCA/account-invoicing/tree/14.0/sale_stock_picking_invoicing
: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-sale_stock_picking_invoicing
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/95/14.0
:alt: Try me on Runbot

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

This module extends Stock Picking Invoicing implementation to Sale, you can define the Sale Creation Invoice Policy, if the invoice should create from Sale Order or Stock Picking, in this case, the information used at invoice come from Sale Order e.g.: Price Unit, Payment Terms, and others fields.

**Table of contents**

.. contents::
:local:

Installation
============

This module depends on:

* sale_management
* stock_picking_invoicing

Configuration
=============

Define Sale Creation Invoice Policy, if the invoice should create in Sale Order or Stock Picking, go to:
Settings > Users & Companies > Companies
or
Sales > Configuration > Settings in Invoicing

Usage
=====

In the case of Stock Picking choose as Policy, the creation of Invoice from Sale Order works only for Service lines. The case of Sale Order with Products and Service lines will create two Invoices.

Known issues / Roadmap
======================

* It is be possible reference multiple sale lines in only one invoice line https://github.com/odoo/odoo/blob/14.0/addons/sale/models/account_move.py#L34, but there are a problem when Posted Invoice:
Issue https://github.com/odoo/odoo/issues/77028
PR with FIX https://github.com/odoo/odoo/pull/77195

Changelog
=========

14.0.1.0.0 (2021-10-15)
~~~~~~~~~~~~~~~~~~~~~~~

* [NEW] Module sale_stock_picking_invoicing based in l10n_br_sale_stock https://github.com/OCA/l10n-brazil/tree/12.0/l10n_br_sale_stock .

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20sale_stock_picking_invoicing%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
~~~~~~~

* Akretion

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

* Magno Costa <magno.costa@akretion.com.br>

Other credits
~~~~~~~~~~~~~

The development of this module has been financially supported by:

* Aketion

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.

.. |maintainer-mbcosta| image:: https://github.com/mbcosta.png?size=40px
:target: https://github.com/mbcosta
:alt: mbcosta

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-mbcosta|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions sale_stock_picking_invoicing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
27 changes: 27 additions & 0 deletions sale_stock_picking_invoicing/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (C) 2021-TODAY Akretion
# @author Magno Costa <magno.costa@akretion.com.br>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Sales Stock Picking Invocing",
"category": "Warehouse Management",
"license": "AGPL-3",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-invoicing",
"version": "14.0.1.0.0",
"maintainers": ["mbcosta"],
"depends": [
"sale_management",
"stock_picking_invoicing",
],
"data": [
"views/res_company_view.xml",
"views/res_config_settings_view.xml",
"views/sale_order_view.xml",
],
"demo": [
"demo/sale_order_demo.xml",
],
"installable": True,
"auto_install": True,
}
194 changes: 194 additions & 0 deletions sale_stock_picking_invoicing/demo/sale_order_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<!-- Show partner_shipping_id in Sale Order -->
<record
id="group_sale_delivery_address_config_settings"
model="res.config.settings"
>
<field name="group_sale_delivery_address">True</field>
</record>

<function model="res.config.settings" name="execute">
<value
model="res.config.settings"
search="[('id', '=',
ref('group_sale_delivery_address_config_settings'))]"
/>
</function>

<!-- Test different Payment Terms -->
<record id="base.res_partner_2" model="res.partner">
<field
name="property_payment_term_id"
ref="account.account_payment_term_15days"
/>
</record>

<!-- Product is Service Type there is not Delivery Order in this cases,
it's seems a mistake, fix here to use in the tests -->
<record id="product.product_product_1" model="product.product">
<field name="invoice_policy">order</field>
</record>

<!-- Test with different shipping address -->
<record id="res_partner_2_address" model="res.partner">
<field eval="1" name="active" />
<field name="is_company" eval="1" />
<field name="name">Deco Addict - Address 2</field>
<field name="parent_id" ref="base.res_partner_2" />
<field
eval="[(6, 0, [ref('base.res_partner_category_14')])]"
name="category_id"
/>
<field name="street">77 Palos Verdes Rd</field>
<field name="city">Pleasant Hill</field>
<field name="state_id" ref='base.state_us_5' />
<field name="zip">94521</field>
<field name="country_id" ref="base.us" />
<field name="type">delivery</field>
<field name="email">deco.addict83@example.com</field>
<field name="phone">(603)-996-3821</field>
<field name="website">http://www.deco-addict.com</field>
<field
name="image_1920"
type="base64"
file="base/static/img/res_partner_2-image.png"
/>
</record>

<!-- Main Company - Different Shipping Address -->
<record id="main_so_sale_stock_picking_invoicing_1" model="sale.order">
<field
name="name"
>sale_stock_picking_invoicing - Different Delivery and Invoice Address</field>
<field name="partner_id" ref="base.res_partner_2" />
<field name="partner_invoice_id" ref="base.res_partner_2" />
<field name="partner_shipping_id" ref="res_partner_2_address" />
<field name="user_id" ref="base.user_admin" />
<field name="pricelist_id" ref="product.list0" />
<field name="payment_term_id" ref="account.account_payment_term_advance" />
<field name="team_id" ref="sales_team.crm_team_1" />
<field name="state">draft</field>
<field name="company_id" ref="base.main_company" />
<field name="note">Note Test</field>
</record>

<record id="main_sl_sale_stock_picking_invoicing_1_1" model="sale.order.line">
<field name="order_id" ref="main_so_sale_stock_picking_invoicing_1" />
<field name="name">[FURN_8855] Drawer</field>
<field name="product_id" ref="product.product_product_27" />
<field name="product_uom_qty">2</field>
<field name="product_uom" ref="uom.product_uom_unit" />
<field name="price_unit">500</field>
</record>

<record id="main_sl_sale_stock_picking_invoicing_1_2" model="sale.order.line">
<field name="order_id" ref="main_so_sale_stock_picking_invoicing_1" />
<field name="name">[FURN_0269] Office Chair Black</field>
<field name="product_id" ref="product.product_product_12" />
<field name="product_uom_qty">2</field>
<field name="product_uom" ref="uom.product_uom_unit" />
<field name="price_unit">500</field>
</record>

<!-- Sale Order with Product and Service -->
<record id="main_so_sale_stock_picking_invoicing_2" model="sale.order">
<field name="name">sale_stock_picking_invoicingk - Product and Service</field>
<field name="partner_id" ref="base.res_partner_2" />
<field name="partner_invoice_id" ref="base.res_partner_2" />
<field name="partner_shipping_id" ref="res_partner_2_address" />
<field name="user_id" ref="base.user_admin" />
<field name="pricelist_id" ref="product.list0" />
<field name="payment_term_id" ref="account.account_payment_term_advance" />
<field name="team_id" ref="sales_team.crm_team_1" />
<field name="state">draft</field>
<field name="company_id" ref="base.main_company" />
<field name="note">Test Note - Product and Service</field>
</record>

<record id="main_sl_sale_stock_picking_invoicing_2_1" model="sale.order.line">
<field name="order_id" ref="main_so_sale_stock_picking_invoicing_2" />
<field name="name">[FURN_8855] Drawer</field>
<field name="product_id" ref="product.product_product_27" />
<field name="product_uom_qty">2</field>
<field name="product_uom" ref="uom.product_uom_unit" />
<field name="price_unit">500</field>
</record>

<record id="main_sl_sale_stock_picking_invoicing_2_2" model="sale.order.line">
<field name="order_id" ref="main_so_sale_stock_picking_invoicing_2" />
<field name="name">Virtual Interior Design</field>
<field name="product_id" ref="product.product_product_1" />
<field name="product_uom_qty">10</field>
<field name="product_uom" ref="uom.product_uom_hour" />
<field name="price_unit">100</field>
</record>

<!-- Groupping Pickings Test -->
<record id="main_so_sale_stock_picking_invoicing_3" model="sale.order">
<field name="name">sale_stock_picking_invoicing - Grouping Pickings</field>
<field name="partner_id" ref="base.res_partner_2" />
<field name="partner_invoice_id" ref="base.res_partner_2" />
<field name="partner_shipping_id" ref="base.res_partner_2" />
<field name="user_id" ref="base.user_admin" />
<field name="pricelist_id" ref="product.list0" />
<field name="payment_term_id" ref="account.account_payment_term_advance" />
<field name="team_id" ref="sales_team.crm_team_1" />
<field name="state">draft</field>
<field name="company_id" ref="base.main_company" />
<field name="note">Test Note</field>
</record>

<record id="main_sl_sale_stock_picking_invoicingk_3_1" model="sale.order.line">
<field name="order_id" ref="main_so_sale_stock_picking_invoicing_3" />
<field name="name">[FURN_8855] Drawer</field>
<field name="product_id" ref="product.product_product_27" />
<field name="product_uom_qty">2</field>
<field name="product_uom" ref="uom.product_uom_unit" />
<field name="price_unit">500</field>
</record>

<record id="main_sl_sale_stock_picking_invoicing_3_2" model="sale.order.line">
<field name="order_id" ref="main_so_sale_stock_picking_invoicing_3" />
<field name="name">[FURN_0269] Office Chair Black</field>
<field name="product_id" ref="product.product_product_12" />
<field name="product_uom_qty">2</field>
<field name="product_uom" ref="uom.product_uom_unit" />
<field name="price_unit">500</field>
</record>

<!-- Groupping Pickings Test -->
<record id="main_so_sale_stock_picking_invoicing_4" model="sale.order">
<field name="name">sale_stock_picking_invoicing - Grouping Pickings</field>
<field name="partner_id" ref="base.res_partner_2" />
<field name="partner_invoice_id" ref="base.res_partner_2" />
<field name="partner_shipping_id" ref="base.res_partner_2" />
<field name="user_id" ref="base.user_admin" />
<field name="pricelist_id" ref="product.list0" />
<field name="payment_term_id" ref="account.account_payment_term_advance" />
<field name="team_id" ref="sales_team.crm_team_1" />
<field name="state">draft</field>
<field name="company_id" ref="base.main_company" />
<field name="note">Test Note</field>
</record>

<record id="main_sl_sale_stock_picking_invoicing_4_1" model="sale.order.line">
<field name="order_id" ref="main_so_sale_stock_picking_invoicing_4" />
<field name="name">[FURN_8855] Drawer</field>
<field name="product_id" ref="product.product_product_27" />
<field name="product_uom_qty">2</field>
<field name="product_uom" ref="uom.product_uom_unit" />
<field name="price_unit">500</field>
</record>

<record id="main_sl_sale_stock_picking_invoicing_4_2" model="sale.order.line">
<field name="order_id" ref="main_so_sale_stock_picking_invoicing_4" />
<field name="name">[FURN_0269] Office Chair Black</field>
<field name="product_id" ref="product.product_product_12" />
<field name="product_uom_qty">2</field>
<field name="product_uom" ref="uom.product_uom_unit" />
<field name="price_unit">500</field>
</record>

</odoo>
7 changes: 7 additions & 0 deletions sale_stock_picking_invoicing/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from . import sale_order_line
from . import stock_move
from . import sale_order
from . import stock_picking
from . import res_company
from . import res_config_settings
from . import stock_rule
20 changes: 20 additions & 0 deletions sale_stock_picking_invoicing/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021-TODAY Akretion
# @author Magno Costa <magno.costa@akretion.com.br>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

sale_create_invoice_policy = fields.Selection(
selection=[
("sale_order", "Sale Order"),
("stock_picking", "Stock Picking"),
],
string="Sale Create Invoice Policy",
help="Define, when Product Type are not service, if Invoice"
" should be create from Sale Order or Stock Picking.",
default="stock_picking",
)
13 changes: 13 additions & 0 deletions sale_stock_picking_invoicing/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (C) 2021-TODAY Akretion
# @author Magno Costa <magno.costa@akretion.com.br>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

sale_create_invoice_policy = fields.Selection(
related="company_id.sale_create_invoice_policy", readonly=False
)
Loading

0 comments on commit 27e6185

Please sign in to comment.