Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12 roulier laposte demo #131

Open
wants to merge 2 commits into
base: 12-roulier-laposte
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions base_delivery_carrier_label/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# Copyright 2013-2015 Yannick Vaucher (Camptocamp SA)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{'name': 'Base module for carrier labels',
'version': '12.0.2.0.0',
'author': "Camptocamp,Akretion,Odoo Community Association (OCA)",
'maintainer': 'Camptocamp',
'category': 'Delivery',
'depends': ['delivery'],
'website': 'https://github.com/OCA/delivery-carrier',
'data': [
'views/delivery.xml',
'views/stock.xml',
'views/res_config.xml',
'views/carrier_account.xml',
'security/ir.model.access.csv',
'security/carrier_security.xml',
'wizard/manifest_wizard_view.xml',
],
'installable': True,
'auto_install': False,
'license': 'AGPL-3',
}
{
"name": "Base module for carrier labels",
"version": "12.0.2.0.0",
"author": "Camptocamp,Akretion,Odoo Community Association (OCA)",
"maintainer": "Camptocamp",
"category": "Delivery",
"depends": ["delivery"],
"website": "https://github.com/OCA/delivery-carrier",
"data": [
"views/delivery.xml",
"views/stock.xml",
"views/res_config.xml",
"views/carrier_account.xml",
"security/ir.model.access.csv",
"security/carrier_security.xml",
"wizard/manifest_wizard_view.xml",
],
"installable": True,
"auto_install": False,
"license": "AGPL-3",
}
18 changes: 8 additions & 10 deletions base_delivery_carrier_label/models/carrier_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@


class CarrierAccount(models.Model):
_name = 'carrier.account'
_description = 'Base account datas'
_name = "carrier.account"
_description = "Base account datas"

@api.model
def _selection_file_format(self):
""" To inherit to add label file types"""
return [('PDF', 'PDF'),
('ZPL', 'ZPL'),
('XML', 'XML')]
return [("PDF", "PDF"), ("ZPL", "ZPL"), ("XML", "XML")]

name = fields.Char(required=True)
account = fields.Char(string='Account Number', required=True)
password = fields.Char(string='Account Password', required=True)
account = fields.Char(string="Account Number", required=True)
password = fields.Char(string="Account Password", required=True)
company_id = fields.Many2one(comodel_name="res.company", string="Company")
file_format = fields.Selection(
selection='_selection_file_format',
string='File Format',
help="Default format of the carrier's label you want to print"
selection="_selection_file_format",
string="File Format",
help="Default format of the carrier's label you want to print",
)
18 changes: 8 additions & 10 deletions base_delivery_carrier_label/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@


class DeliveryCarrier(models.Model):
_inherit = 'delivery.carrier'
_inherit = "delivery.carrier"

delivery_type = fields.Selection(oldname='carrier_type')
code = fields.Char(
help="Delivery Method Code (according to carrier)",
)
delivery_type = fields.Selection(oldname="carrier_type")
code = fields.Char(help="Delivery Method Code (according to carrier)",)
description = fields.Text()
available_option_ids = fields.One2many(
comodel_name='delivery.carrier.option',
inverse_name='carrier_id',
string='Option',
comodel_name="delivery.carrier.option",
inverse_name="carrier_id",
string="Option",
)

@api.multi
def default_options(self):
""" Returns default and available options for a carrier """
options = self.env['delivery.carrier.option'].browse()
options = self.env["delivery.carrier.option"].browse()
for available_option in self.available_option_ids:
if (available_option.mandatory or available_option.by_default):
if available_option.mandatory or available_option.by_default:
options |= available_option
return options
25 changes: 12 additions & 13 deletions base_delivery_carrier_label/models/delivery_carrier_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,28 @@ class DeliveryCarrierOption(models.Model):
to be added on delivery orders

"""
_name = 'delivery.carrier.option'
_description = 'Delivery carrier option'
_inherits = {'delivery.carrier.template.option': 'tmpl_option_id'}

_name = "delivery.carrier.option"
_description = "Delivery carrier option"
_inherits = {"delivery.carrier.template.option": "tmpl_option_id"}

mandatory = fields.Boolean(
help="If checked, this option is necessarily applied "
"to the delivery order"
help="If checked, this option is necessarily applied " "to the delivery order"
)
by_default = fields.Boolean(
string='Applied by Default',
string="Applied by Default",
help="By check, user can choose to apply this option "
"to each Delivery Order\n using this delivery method"
"to each Delivery Order\n using this delivery method",
)
tmpl_option_id = fields.Many2one(
comodel_name='delivery.carrier.template.option',
string='Option',
comodel_name="delivery.carrier.template.option",
string="Option",
required=True,
ondelete="cascade",
)
carrier_id = fields.Many2one(comodel_name='delivery.carrier',
string='Carrier')
carrier_id = fields.Many2one(comodel_name="delivery.carrier", string="Carrier")
readonly_flag = fields.Boolean(
string='Readonly Flag',
string="Readonly Flag",
help="When True, help to prevent the user to modify some fields "
"option (if attribute is defined in the view)"
"option (if attribute is defined in the view)",
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@

class DeliveryCarrierTemplateOption(models.Model):
""" Available options for a carrier (partner) """
_name = 'delivery.carrier.template.option'
_description = 'Delivery carrier template option'

partner_id = fields.Many2one(comodel_name='res.partner',
string='Partner Carrier')
_name = "delivery.carrier.template.option"
_description = "Delivery carrier template option"

partner_id = fields.Many2one(comodel_name="res.partner", string="Partner Carrier")
name = fields.Char(readonly=True)
code = fields.Char(readonly=True)
description = fields.Char(
readonly=True,
help="Allow to define a more complete description "
"than in the name field."
help="Allow to define a more complete description " "than in the name field.",
)
18 changes: 7 additions & 11 deletions base_delivery_carrier_label/models/shipping_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@
class ShippingLabel(models.Model):
""" Child class of ir attachment to identify which are labels """

_name = 'shipping.label'
_inherits = {'ir.attachment': 'attachment_id'}
_name = "shipping.label"
_inherits = {"ir.attachment": "attachment_id"}
_description = "Shipping Label"

file_type = fields.Char(
string='File type',
default='pdf',
)
package_id = fields.Many2one(comodel_name='stock.quant.package',
string='Pack')
file_type = fields.Char(string="File type", default="pdf",)
package_id = fields.Many2one(comodel_name="stock.quant.package", string="Pack")
attachment_id = fields.Many2one(
comodel_name='ir.attachment',
string='Attachement',
comodel_name="ir.attachment",
string="Attachement",
required=True,
ondelete='cascade',
ondelete="cascade",
)
15 changes: 7 additions & 8 deletions base_delivery_carrier_label/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@


class StockMoveLine(models.Model):
_inherit = 'stock.move.line'
_inherit = "stock.move.line"

weight = fields.Float(
digits=dp.get_precision('Stock Weight'),
help="Weight of the pack_operation"
digits=dp.get_precision("Stock Weight"), help="Weight of the pack_operation"
)

@api.multi
Expand All @@ -27,8 +26,8 @@ def get_weight(self):
the sum of the weight of [self]
"""
total_weight = 0
kg = self.env.ref('uom.product_uom_kgm').id
units = self.env.ref('uom.product_uom_unit').id
kg = self.env.ref("uom.product_uom_kgm").id
units = self.env.ref("uom.product_uom_unit").id
allowed = (False, kg, units)
cant_calc_total = False
for operation in self:
Expand All @@ -37,11 +36,11 @@ def get_weight(self):
# if not defined we assume it's in kg
if product.uom_id.id not in allowed:
_logger.warning(
'Type conversion not implemented for product %s' %
product.id)
"Type conversion not implemented for product %s" % product.id
)
cant_calc_total = True

operation.weight = (product.weight * operation.product_qty)
operation.weight = product.weight * operation.product_qty

total_weight += operation.weight

Expand Down
Loading