|
@@ -520,7 +520,7 @@ class Purchases(http.Controller):
|
|
|
'''
|
|
|
Number to invoice
|
|
|
'''
|
|
|
- def validate_invoice(self, invoice_ids):
|
|
|
+ def validate_invoice(self, invoice_ids, type=None):
|
|
|
assert len(invoice_ids) == 1
|
|
|
|
|
|
invoice = request.env['account.invoice'].browse(invoice_ids)
|
|
@@ -528,6 +528,13 @@ class Purchases(http.Controller):
|
|
|
invoice.action_number()
|
|
|
invoice.invoice_validate()
|
|
|
|
|
|
+ if type != 'purchase':
|
|
|
+ name = 'GASTO' + invoice.name[invoice.name.index('/'):]
|
|
|
+ invoice.write({
|
|
|
+ 'number': name,
|
|
|
+ 'internal_number': name
|
|
|
+ })
|
|
|
+
|
|
|
'''
|
|
|
Create voucher
|
|
|
'''
|
|
@@ -634,7 +641,8 @@ class Purchases(http.Controller):
|
|
|
'''
|
|
|
@http.route('/eiru_purchases/process', type='json', auth='user', methods=['POST'], cors='*')
|
|
|
def process_purchase(self, **kw):
|
|
|
- self.make_info_log('Processing purchase...')
|
|
|
+ mode = kw.get('mode')
|
|
|
+ self.make_info_log('Processing {}'.format(mode))
|
|
|
|
|
|
# Get date
|
|
|
date_now = datetime.now().strftime(DATE_FORMAT)
|
|
@@ -650,7 +658,7 @@ class Purchases(http.Controller):
|
|
|
|
|
|
invoice = None
|
|
|
|
|
|
- if kw.get('mode') == 'purchase':
|
|
|
+ if mode == 'purchase':
|
|
|
# Create purchase order
|
|
|
purchase_order = self.create_purchase_order(kw.get('supplierId'), kw.get('items'), date_now, currency_id, pricelist_id, kw.get('paymentTermId'))
|
|
|
self.make_info_log('Purchase order created')
|
|
@@ -679,7 +687,7 @@ class Purchases(http.Controller):
|
|
|
self.make_info_log('Account move created')
|
|
|
|
|
|
# Validate invoice
|
|
|
- self.validate_invoice(invoice_ids)
|
|
|
+ self.validate_invoice(invoice_ids, mode)
|
|
|
self.make_info_log('Invoice validated')
|
|
|
|
|
|
# Create account voucher
|