Skip to content

Commit

Permalink
[FIX] account_receipt_sale: invoice word occurrences
Browse files Browse the repository at this point in the history
  • Loading branch information
primes2h committed Mar 22, 2024
1 parent 3817502 commit 75e2ff8
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 6 deletions.
2 changes: 1 addition & 1 deletion account_receipt_sale/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Receipts from sales
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6f068a91ec4cb239575ef3388d18a368a9622ae2763736dd37ecd1adaa9e954c
!! source digest: sha256:0eac2bad09a214cf91e19d6b619ab814d959e7235012f77c1ca17c2470d4eef9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
5 changes: 4 additions & 1 deletion account_receipt_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2016-2022 Lorenzo Battistini
# Copyright 2018-2019 Simone Rubino
# Copyright 2019 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo)
# Copyright 2019-2024 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo)
# Copyright 2020 Giovanni Serra - GSLab.it
# Copyright 2023 Simone Rubino - TAKOBI
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
Expand All @@ -23,7 +23,10 @@
"sale",
],
"data": [
"wizard/sale_make_invoice.xml",
"views/sale_views.xml",
"security/sale_security.xml",
"security/ir.model.access.csv",
],
"pre_init_hook": "rename_old_italian_module",
"post_init_hook": "migrate_corrispettivi_data",
Expand Down
2 changes: 2 additions & 0 deletions account_receipt_sale/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sale_advance_payment_rec,access.sale.advance.payment.rec,model_sale_advance_payment_rec,sales_team.group_sale_salesman,1,1,1,0
8 changes: 8 additions & 0 deletions account_receipt_sale/security/sale_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="sale_advance_payment_rec_rule" model="ir.rule">
<field name="name">Sales Advance Payment Receipt Rule</field>
<field name="model_id" ref="model_sale_advance_payment_rec" />
<field name="domain_force">[('create_uid', '=', user.id)]</field>
</record>
</odoo>
3 changes: 2 additions & 1 deletion account_receipt_sale/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -366,7 +367,7 @@ <h1 class="title">Receipts from sales</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6f068a91ec4cb239575ef3388d18a368a9622ae2763736dd37ecd1adaa9e954c
!! source digest: sha256:0eac2bad09a214cf91e19d6b619ab814d959e7235012f77c1ca17c2470d4eef9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-invoicing/tree/14.0/account_receipt_sale"><img alt="OCA/account-invoicing" src="https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoicing-14-0/account-invoicing-14-0-account_receipt_sale"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Based on <cite>account_receipt_journal</cite>, this module allows to create receipts from sale orders.</p>
Expand Down
42 changes: 42 additions & 0 deletions account_receipt_sale/views/sale_views.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
~ Copyright 2022 Simone Rubino - TAKOBI
~ Copyright 2024 Sergio Zanchetta - PNLUG APS
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
Expand All @@ -9,6 +10,7 @@
<record id="view_order_form" model="ir.ui.view">
<field name="name">sale.order.form.receipts</field>
<field name="model">sale.order</field>
<field name="priority" eval="110" />
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<group name="sale_info" position="inside">
Expand All @@ -25,6 +27,46 @@
<field name="receipt_count" widget="statinfo" string="Receipts" />
</button>
</button>
<button
name="%(sale.action_view_sale_advance_payment_inv)d"
class="btn-primary"
position="replace"
>
<button
name="%(sale.action_view_sale_advance_payment_inv)d"
string="Create Invoice"
type="action"
class="btn-primary"
attrs="{'invisible': ['|', ('invoice_status', '!=', 'to invoice'), ('receipts', '!=', False)]}"
/>
<button
name="%(account_receipt_sale.action_view_sale_advance_payment_rec)d"
string="Create Receipt"
type="action"
class="btn-primary"
attrs="{'invisible': ['|', ('invoice_status', '!=', 'to invoice'), ('receipts', '!=', True)]}"
/>
</button>
<button
name="%(sale.action_view_sale_advance_payment_inv)d"
context="{'default_advance_payment_method': 'percentage'}"
position="replace"
>
<button
name="%(sale.action_view_sale_advance_payment_inv)d"
string="Create Invoice"
type="action"
context="{'default_advance_payment_method': 'percentage'}"
attrs="{'invisible': ['|', '|', ('invoice_status', '!=', 'no'), ('state', '!=', 'sale'), ('receipts', '!=', False)]}"
/>
<button
name="%(account_receipt_sale.action_view_sale_advance_payment_rec)d"
string="Create Receipt"
type="action"
context="{'default_advance_payment_method': 'percentage'}"
attrs="{'invisible': ['|', '|', ('invoice_status', '!=', 'no'), ('state', '!=', 'sale'), ('receipts', '!=', True)]}"
/>
</button>
</field>
</record>
</odoo>
25 changes: 22 additions & 3 deletions account_receipt_sale/wizard/sale_make_invoice.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
from odoo import models
from odoo import fields, models


class SaleAdvancePaymentInv(models.TransientModel):
class SaleAdvancePaymentRec(models.TransientModel):
_name = "sale.advance.payment.rec"
_inherit = "sale.advance.payment.inv"

advance_payment_method = fields.Selection(selection="_get_advance_payment_method")

def _get_advance_payment_method(self):
order_ids = self._context.get("active_ids", [])
orders = self.env["sale.order"].browse(order_ids)
if all(orders.mapped("receipts")):
return [
("delivered", "Regular receipt"),
("percentage", "Down payment (percentage)"),
("fixed", "Down payment (fixed amount)"),
]
else:
return [

Check warning on line 20 in account_receipt_sale/wizard/sale_make_invoice.py

View check run for this annotation

Codecov / codecov/patch

account_receipt_sale/wizard/sale_make_invoice.py#L20

Added line #L20 was not covered by tests
("delivered", "Regular invoice"),
("percentage", "Down payment (percentage)"),
("fixed", "Down payment (fixed amount)"),
]

def _prepare_invoice_values(self, order, name, amount, so_line):
invoice_vals = super(SaleAdvancePaymentInv, self)._prepare_invoice_values(
invoice_vals = super(SaleAdvancePaymentRec, self)._prepare_invoice_values(

Check warning on line 27 in account_receipt_sale/wizard/sale_make_invoice.py

View check run for this annotation

Codecov / codecov/patch

account_receipt_sale/wizard/sale_make_invoice.py#L27

Added line #L27 was not covered by tests
order, name, amount, so_line
)
if order.receipts:
Expand Down
123 changes: 123 additions & 0 deletions account_receipt_sale/wizard/sale_make_invoice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
~ Copyright 2024 Sergio Zanchetta - PNLUG APS
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_sale_advance_payment_rec" model="ir.ui.view">
<field name="name">Receipt Orders</field>
<field name="model">sale.advance.payment.rec</field>
<field name="arch" type="xml">
<form string="Receipt Sales Order">
<p class="oe_grey">
Receipts will be created in draft so that you can review
them before validation.
</p>
<group>
<field
name="count"
attrs="{'invisible': [('count','=', 1)]}"
readonly="True"
/>
<field
name="advance_payment_method"
string="Create Receipt"
class="oe_inline"
widget="radio"
attrs="{'invisible': [('count','&gt;',1)]}"
/>
<field name="has_down_payments" invisible="1" />
<label
for="deduct_down_payments"
string="Pippo"
attrs="{'invisible': ['|', ('has_down_payments', '=', False), ('advance_payment_method', '!=', 'delivered')]}"
/>
<div
attrs="{'invisible': ['|', ('has_down_payments', '=', False), ('advance_payment_method', '!=', 'delivered')]}"
id="down_payment_details"
>
<field name="deduct_down_payments" nolabel="1" />
<label for="deduct_down_payments" />
</div>
<field
name="product_id"
context="{'default_invoice_policy': 'order'}"
class="oe_inline"
invisible="1"
/>
<label
for="amount"
attrs="{'invisible': [('advance_payment_method', 'not in', ('fixed','percentage'))]}"
/>
<div
attrs="{'invisible': [('advance_payment_method', 'not in', ('fixed','percentage'))]}"
id="payment_method_details"
>
<field name="currency_id" invisible="1" />
<field
name="fixed_amount"
attrs="{'required': [('advance_payment_method', '=', 'fixed')], 'invisible': [('advance_payment_method', '!=','fixed')]}"
class="oe_inline"
/>
<field
name="amount"
attrs="{'required': [('advance_payment_method', '=', 'percentage')], 'invisible': [('advance_payment_method', '!=', 'percentage')]}"
class="oe_inline"
/>
<span
attrs="{'invisible': [('advance_payment_method', '!=', 'percentage')]}"
class="oe_inline"
>%</span>
</div>
<field
name="deposit_account_id"
options="{'no_create': True}"
class="oe_inline"
attrs="{'invisible': ['|', ('advance_payment_method', 'not in', ('fixed', 'percentage')), ('product_id', '!=', False)]}"
groups="account.group_account_manager"
/>
<field
name="deposit_taxes_id"
class="oe_inline"
widget="many2many_tags"
domain="[('type_tax_use','=','sale')]"
attrs="{'invisible': ['|', ('advance_payment_method', 'not in', ('fixed', 'percentage')), ('product_id', '!=', False)]}"
/>
</group>
<footer>
<button
name="create_invoices"
id="create_invoice_open"
string="Create and View Receipt"
type="object"
context="{'open_invoices': True}"
class="btn-primary"
/>
<button
name="create_invoices"
id="create_invoice"
string="Create Receipt"
type="object"
/>
<button
string="Cancel"
class="btn-secondary"
special="cancel"
/>
</footer>
</form>
</field>
</record>

<record id="action_view_sale_advance_payment_rec" model="ir.actions.act_window">
<field name="name">Create receipts</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.advance.payment.rec</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<!-- TODO: check if we need this -->
<field name="binding_model_id" ref="sale.model_sale_order" />
<field name="binding_view_types">list</field>
</record>

</odoo>

0 comments on commit 75e2ff8

Please sign in to comment.