Browse Source

[MIG] compute_purchase_order: migration to 11.0

- followed oca guidelines
- not tested on odoo 11.0
pull/145/head
Vincent Van Rossem 5 years ago
committed by robin.keunen
parent
commit
713235e0e3
  1. 3
      compute_purchase_order/__manifest__.py
  2. 11
      compute_purchase_order/models/computed_purchase_order.py
  3. 11
      compute_purchase_order/models/computed_purchase_order_line.py
  4. 1
      compute_purchase_order/models/product_template.py
  5. 1
      compute_purchase_order/models/purchase_order.py

3
compute_purchase_order/__manifest__.py

@ -1,7 +1,6 @@
# -*- encoding: utf-8 -*-
{
'name': 'Computed Purchase Order',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'category': 'Purchase Order',
'description': """ todo """,
'author': 'Coop IT Easy',

11
compute_purchase_order/models/computed_purchase_order.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, SUPERUSER_ID
from odoo.exceptions import ValidationError
@ -83,12 +82,12 @@ class ComputedPurchaseOrder(models.Model):
suppliers.add(main_supplier_id)
if len(suppliers) == 0:
raise ValidationError(u'No supplier is set for selected articles.')
raise ValidationError('No supplier is set for selected articles.')
elif len(suppliers) == 1:
return suppliers.pop()
else:
raise ValidationError(
u'You must select article from a single supplier.')
'You must select article from a single supplier.')
def _create_order_lines(self):
product_tmpl_ids = self._get_selected_products()
@ -113,7 +112,7 @@ class ComputedPurchaseOrder(models.Model):
.browse(supplier_id)
.name)
name = u'CPO {} {}'.format(
name = 'CPO {} {}'.format(
supplier_name,
fields.Date.today())
else:
@ -155,8 +154,8 @@ class ComputedPurchaseOrder(models.Model):
self.ensure_one()
if sum(self.order_line_ids.mapped('purchase_quantity')) == 0:
raise ValidationError(u'You need at least a product to generate '
u'a Purchase Order')
raise ValidationError('You need at least a product to generate '
'a Purchase Order')
PurchaseOrder = self.env['purchase.order']
PurchaseOrderLine = self.env['purchase.order.line']

11
compute_purchase_order/models/computed_purchase_order_line.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import logging
from odoo import models, fields, api
@ -151,13 +150,13 @@ class ComputedPurchaseOrderLine(models.Model):
if len(si) == 0:
raise ValidationError(
u'No supplier information set for {name}'
'No supplier information set for {name}'
.format(name=cpol.product_template_id.name))
elif len(si) == 1:
cpol.supplierinfo_id = si
else:
_logger.warning(
u'product {name} has several suppliers, chose last'
'product {name} has several suppliers, chose last'
.format(name=cpol.product_template_id.name)
)
si = si.sorted(key=lambda r: r.create_date, reverse=True)
@ -167,10 +166,10 @@ class ComputedPurchaseOrderLine(models.Model):
def _check_minimum_purchase_quantity(self):
for cpol in self:
if cpol.purchase_quantity < 0:
raise ValidationError(u'Purchase quantity for {product_name} must be greater than 0' # noqa
raise ValidationError('Purchase quantity for {product_name} must be greater than 0' # noqa
.format(product_name=cpol.product_template_id.name))
elif 0 < cpol.purchase_quantity < cpol.minimum_purchase_qty:
raise ValidationError(u'Purchase quantity for {product_name} must be greater than {min_qty}' # noqa
raise ValidationError('Purchase quantity for {product_name} must be greater than {min_qty}' # noqa
.format(product_name=cpol.product_template_id.name,
min_qty=cpol.minimum_purchase_qty))
@ -191,6 +190,6 @@ class ComputedPurchaseOrderLine(models.Model):
return products[0]
else:
raise ValidationError(
u'%s:%s template has no variant set'
'%s:%s template has no variant set'
% (self.product_template_id.id, self.product_template_id.name)
)

1
compute_purchase_order/models/product_template.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api

1
compute_purchase_order/models/purchase_order.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields

Loading…
Cancel
Save