Skip to content

Commit

Permalink
[FIX] contract_sale_generation: it doesn't create sales (OCA#141)
Browse files Browse the repository at this point in the history
* Change the method called in the view
* Complete the create_invoice method
* Bump version + authoring
* Correct bad call of method
  Small Documentation
* Add super call in python test
* FIX bad field names causing bad quantities in sale.order.line
  • Loading branch information
flotho authored and OCA-git-bot committed Mar 21, 2023
1 parent a3fdfbc commit 8325f14
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions contract_sale_generation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Contributors
------------

* Angel Moya <angel.moya@pesol.es>
* Florent THOMAS <florent.thomas@mind-and-go.com>

Maintainer
----------
Expand Down
2 changes: 1 addition & 1 deletion contract_sale_generation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{
'name': 'Contracts Management - Recurring Sales',
'version': '10.0.2.0.0',
'version': '10.0.3.0.0',
'category': 'Contract Management',
'license': 'AGPL-3',
'author': "PESOL, "
Expand Down
17 changes: 14 additions & 3 deletions contract_sale_generation/models/account_analytic_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def _prepare_sale_line(self, line, order_id):
sale_line = self.env['sale.order.line'].new({
'order_id': order_id,
'product_id': line.product_id.id,
'proudct_uom_qty': line.quantity,
'proudct_uom_id': line.uom_id.id,
'product_qty': line.quantity,
'product_uom_qty': line.quantity,
'product_uom': line.uom_id.id,
})
# Get other invoice line values from product onchange
# Get other sale line values from product onchange
sale_line.product_id_change()
sale_line_vals = sale_line._convert_to_write(sale_line._cache)
# Insert markers
Expand Down Expand Up @@ -66,6 +67,11 @@ def _prepare_sale(self):

@api.multi
def _create_invoice(self):
"""
Create invoices
@param self: single record of account.invoice
@return: MUST return an invoice recordset
"""
self.ensure_one()
if self.type == 'invoice':
return super(AccountAnalyticAccount, self)._create_invoice()
Expand All @@ -74,6 +80,11 @@ def _create_invoice(self):

@api.multi
def _create_sale(self):
"""
Create Sale orders
@param self: single record of sale.order
@return: MUST return a sale.order recordset
"""
self.ensure_one()
if self.type == 'sale':
sale_vals = self._prepare_sale()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<attribute name="attrs">{'invisible': ['|',('recurring_invoices','!=',True),('type','!=','invoice')]}</attribute>
</xpath>
<xpath expr="//button[@name='recurring_create_invoice']" position="before">
<button name="recurring_create_invoice"
<button name="recurring_create_sale"
type="object"
attrs="{'invisible': ['|',('recurring_invoices','!=',True),('type','!=','sale')]}"
string="Create sales"
Expand Down

0 comments on commit 8325f14

Please sign in to comment.