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', 'name': 'Computed Purchase Order',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'category': 'Purchase Order', 'category': 'Purchase Order',
'description': """ todo """, 'description': """ todo """,
'author': 'Coop IT Easy', '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 import models, fields, api, SUPERUSER_ID
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
@ -83,12 +82,12 @@ class ComputedPurchaseOrder(models.Model):
suppliers.add(main_supplier_id) suppliers.add(main_supplier_id)
if len(suppliers) == 0: 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: elif len(suppliers) == 1:
return suppliers.pop() return suppliers.pop()
else: else:
raise ValidationError( raise ValidationError(
u'You must select article from a single supplier.')
'You must select article from a single supplier.')
def _create_order_lines(self): def _create_order_lines(self):
product_tmpl_ids = self._get_selected_products() product_tmpl_ids = self._get_selected_products()
@ -113,7 +112,7 @@ class ComputedPurchaseOrder(models.Model):
.browse(supplier_id) .browse(supplier_id)
.name) .name)
name = u'CPO {} {}'.format(
name = 'CPO {} {}'.format(
supplier_name, supplier_name,
fields.Date.today()) fields.Date.today())
else: else:
@ -155,8 +154,8 @@ class ComputedPurchaseOrder(models.Model):
self.ensure_one() self.ensure_one()
if sum(self.order_line_ids.mapped('purchase_quantity')) == 0: 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'] PurchaseOrder = self.env['purchase.order']
PurchaseOrderLine = self.env['purchase.order.line'] 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 import logging
from odoo import models, fields, api from odoo import models, fields, api
@ -151,13 +150,13 @@ class ComputedPurchaseOrderLine(models.Model):
if len(si) == 0: if len(si) == 0:
raise ValidationError( raise ValidationError(
u'No supplier information set for {name}'
'No supplier information set for {name}'
.format(name=cpol.product_template_id.name)) .format(name=cpol.product_template_id.name))
elif len(si) == 1: elif len(si) == 1:
cpol.supplierinfo_id = si cpol.supplierinfo_id = si
else: else:
_logger.warning( _logger.warning(
u'product {name} has several suppliers, chose last'
'product {name} has several suppliers, chose last'
.format(name=cpol.product_template_id.name) .format(name=cpol.product_template_id.name)
) )
si = si.sorted(key=lambda r: r.create_date, reverse=True) 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): def _check_minimum_purchase_quantity(self):
for cpol in self: for cpol in self:
if cpol.purchase_quantity < 0: 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)) .format(product_name=cpol.product_template_id.name))
elif 0 < cpol.purchase_quantity < cpol.minimum_purchase_qty: 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, .format(product_name=cpol.product_template_id.name,
min_qty=cpol.minimum_purchase_qty)) min_qty=cpol.minimum_purchase_qty))
@ -191,6 +190,6 @@ class ComputedPurchaseOrderLine(models.Model):
return products[0] return products[0]
else: else:
raise ValidationError( 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) % (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 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 from odoo import models, fields

Loading…
Cancel
Save