Skip to content

Commit

Permalink
temp rebasing PR 710 (017d2b4)
Browse files Browse the repository at this point in the history
  • Loading branch information
roboadhoc committed Jan 17, 2024
2 parents 92f76d4 + 017d2b4 commit 8f17d8e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 deletions.
5 changes: 3 additions & 2 deletions sale_gathering/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Sale Gathering',
'version': '13.0.1.0.0',
'version': "16.0.1.0.0",
'category': 'Sales & Stock',
'sequence': 14,
'summary': '',
Expand All @@ -31,13 +31,14 @@
'depends': [
'account',
'sale_stock_ux',
'l10n_ar_sale'
],
'data': [
'views/sale_order_views.xml',
],
'demo': [
],
'installable': False,
'installable': True,
'auto_install': False,
'application': False,
}
1 change: 1 addition & 0 deletions sale_gathering/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
##############################################################################
from . import sale_order
from . import sale_order_line
from . import account_move
17 changes: 17 additions & 0 deletions sale_gathering/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import models


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

def action_post(self):
down_payment_line = self.line_ids.filtered(lambda line: line.is_downpayment and line.sale_line_ids.order_id.is_gathering)
if down_payment_line:
tax_id = down_payment_line.sale_line_ids.tax_id
price_unit = down_payment_line.sale_line_ids.price_unit
res = super(AccountMove, self).action_post()
if down_payment_line:
for line in down_payment_line:
line.sale_line_ids.tax_id = tax_id
line.sale_line_ids.price_unit = price_unit
return res
4 changes: 3 additions & 1 deletion sale_gathering/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SaleOrder(models.Model):
'order_line.price_unit_with_tax',
'order_line.qty_invoiced',
'order_line.is_downpayment',
'state'
)
def _compute_gathering_balance(self):
self.gathering_balance = 0.0
Expand All @@ -35,11 +36,12 @@ def _compute_gathering_balance(self):

def _get_invoiceable_lines(self, final=False):
"""Return the invoiceable lines for order `self`."""
invoiceable_lines = super()._get_invoiceable_lines(final=False)
invoiceable_lines = super()._get_invoiceable_lines(final=final)
if self.is_gathering and self.gathering_balance > 0.0:
for line in self.order_line.filtered('is_downpayment'):
if final:
invoiceable_lines |= line
invoiceable_lines = invoiceable_lines.filtered(lambda line: line.display_type != 'line_section')
return invoiceable_lines

@api.constrains('is_gathering', 'amount_total')
Expand Down
12 changes: 2 additions & 10 deletions sale_gathering/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@ class SaleOrderLine(models.Model):

_inherit = 'sale.order.line'

@api.onchange('product_uom', 'product_uom_qty')
def product_uom_change(self):
price_unit = self.price_unit
res = super().product_uom_change()
if self.order_id.is_gathering:
self.price_unit = price_unit
return res

def _prepare_invoice_line(self):
result = super()._prepare_invoice_line()
def _prepare_invoice_line(self, **optional_values):
result = super()._prepare_invoice_line(**optional_values)
if self.is_downpayment and self._context.get(
'invoice_gathering', False):
lines = self.order_id.order_line.filtered(
Expand Down
8 changes: 4 additions & 4 deletions sale_gathering/views/sale_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="require_payment" position="after">
<field name="client_order_ref" position="before">
<field name="is_gathering"/>
</field>
<button name="%(sale.action_view_sale_advance_payment_inv)d" position="attributes">
<attribute name="context">{'default_advance_payment_method': is_gathering and 'invoice_gathering_zero' or 'delivered'}</attribute>
</button>
<button name="%(sale.action_view_sale_advance_payment_inv)d" position="after">
<button name="%(sale.action_view_sale_advance_payment_inv)d" string="Create Gathering Invoice" type="action" context="{'default_advance_payment_method': 'fixed'}" attrs="{'invisible': ['|','|', ('is_gathering', '==', False), ('amount_total', '>', 0.0),('state', '!=' ,'sale')]}"/>
<button name="%(sale.action_view_sale_advance_payment_inv)d" string="Create Gathering Invoice" type="action" context="{'default_advance_payment_method': 'fixed'}" attrs="{'invisible': ['|', ('is_gathering', '==', False),('state', '!=' ,'sale')]}"/>
</button>
<field name="amount_total" position="after">
<group name="sale_total" position="inside">
<field name="gathering_balance" widget="monetary" options="{'currency_field': 'currency_id'}"/>
</field>
</group>
</field>
</record>
</odoo>
5 changes: 3 additions & 2 deletions sale_gathering/wizards/sale_advance_payment_inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class SaleAdvancePaymentInvWizard(models.TransientModel):
_inherit = "sale.advance.payment.inv"

advance_payment_method = fields.Selection(selection_add=[
('invoice_gathering_zero', 'Factura en cero descontando acopio'),
])
('invoice_gathering_zero', 'Factura en cero descontando acopio'),],
ondelete={'invoice_gathering_zero': 'cascade'},
)


def _prepare_so_line(self, order, analytic_tag_ids, tax_ids, amount):
Expand Down

0 comments on commit 8f17d8e

Please sign in to comment.