Add custom global to party
This commit is contained in:
parent
a92bc79e53
commit
289737f38a
|
@ -80,6 +80,7 @@ def register():
|
|||
production.ProductionTask,
|
||||
party.Party,
|
||||
party.Company,
|
||||
party.CustomsGlobal,
|
||||
charge.ExportationCharge,
|
||||
charge.ExportationPort,
|
||||
charge.ExportationChargeLine,
|
||||
|
|
7
crop.py
7
crop.py
|
@ -364,7 +364,6 @@ class FarmingCrop(Workflow, ModelSQL, ModelView):
|
|||
for act in crop.variety.activities:
|
||||
_date = crop.start_date + timedelta(
|
||||
weeks=act.time_of_realization)
|
||||
print('Symbol....', act.uom_time.symbol)
|
||||
work_time = act.work_time * crop.total_plants
|
||||
if act.uom_time.symbol == 'min':
|
||||
_cost = round((act.cost_per_hour / 60) * work_time, 2)
|
||||
|
@ -621,7 +620,7 @@ class CropActivity(Workflow, ModelSQL, ModelView):
|
|||
], 'State', readonly=True, required=True)
|
||||
|
||||
@classmethod
|
||||
def generateShipment(cls, records):
|
||||
def generate_shipment(cls, records):
|
||||
pool = Pool()
|
||||
company = Transaction().context.get('company')
|
||||
Supply = pool.get('farming.crop.activity.supply')
|
||||
|
@ -648,7 +647,7 @@ class CropActivity(Workflow, ModelSQL, ModelView):
|
|||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def generateShipmentButton(cls, records):
|
||||
def generate_shipment_button(cls, records):
|
||||
pass
|
||||
|
||||
def _move(self, activity, from_location, to_location, company, product,
|
||||
|
@ -790,7 +789,7 @@ class CropActivity(Workflow, ModelSQL, ModelView):
|
|||
def production(cls, records):
|
||||
for record in records:
|
||||
#cls.create_shipment(record)
|
||||
cls.generateShipment([record])
|
||||
cls.generate_shipment([record])
|
||||
record.set_number()
|
||||
|
||||
def set_number(self):
|
||||
|
|
108
exportation.py
108
exportation.py
|
@ -1,46 +1,45 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from concurrent.futures import process
|
||||
import copy
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from multiprocessing import pool
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.wizard import Wizard, StateView, StateTransition, Button
|
||||
from trytond.modules.company import CompanyReport
|
||||
# from trytond.report import Report
|
||||
# from trytond.wizard import Wizard, StateReport, StateView, Button
|
||||
|
||||
STATES = {
|
||||
'readonly': (Eval('state') != 'draft'),
|
||||
}
|
||||
|
||||
|
||||
class DEX(Workflow, ModelSQL, ModelView):
|
||||
"DEX"
|
||||
__name__ = "exportation.dex"
|
||||
|
||||
|
||||
_rec_name = 'number'
|
||||
number = fields.Char('Number', states=STATES)
|
||||
|
||||
issue_date = fields.Date('Issue Date', required=True,
|
||||
states=STATES)
|
||||
issue_date = fields.Date('Issue Date', required=True, states=STATES)
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states=STATES)
|
||||
states=STATES)
|
||||
# freight_forwader = fields.Many2One('party.party', 'Freight Forwader',
|
||||
# required=True, select=True)
|
||||
customer = fields.Many2One('party.party', 'Customer', select=True,
|
||||
states=STATES, required=True)
|
||||
states=STATES, required=True)
|
||||
|
||||
invoice = fields.Many2One('account.invoice', 'invoice', states=STATES, domain=[
|
||||
('party', '=', Eval('customer')),
|
||||
('company', '=', Eval('company')),
|
||||
])
|
||||
invoice_exchange_rate = fields.Float('Invoice Exchange Rate', digits=(16, 2))
|
||||
currency = fields.Many2One('currency.currency', 'Currency', states=STATES, required=True)
|
||||
invoice_exchange_rate = fields.Float('Invoice Exchange Rate',
|
||||
digits=(16, 2))
|
||||
currency = fields.Many2One('currency.currency', 'Currency', states=STATES,
|
||||
required=True)
|
||||
invoiced_amount = fields.Numeric('Invoiced Amount', digits=(16, 2),
|
||||
states=STATES)
|
||||
states=STATES)
|
||||
description = fields.Char('Description', states=STATES)
|
||||
lines = fields.One2Many('exportation.dex.line', 'dex', 'Lines')
|
||||
state = fields.Selection([
|
||||
|
@ -52,9 +51,9 @@ class DEX(Workflow, ModelSQL, ModelView):
|
|||
digits=(16, 2), readonly=True), 'get_amounts')
|
||||
amount_for_exchange = fields.Function(fields.Numeric('Amount For Exchange',
|
||||
digits=(16, 2), readonly=True), 'get_amounts')
|
||||
|
||||
conversion_invoiced_amount = fields.Function(fields.Numeric('Conversion Invoiced Amount',
|
||||
digits=(16,2), readonly=True), 'get_conversion_of_invoiced_amount')
|
||||
conversion_invoiced_amount = fields.Function(fields.Numeric(
|
||||
'Conversion Invoiced Amount', digits=(16, 2), readonly=True),
|
||||
'get_conversion_of_invoiced_amount')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -133,7 +132,7 @@ class DEX(Workflow, ModelSQL, ModelView):
|
|||
self.currency = self.invoice.currency
|
||||
self.invoiced_amount = self.invoice.total_amount
|
||||
self.on_change_currency()
|
||||
|
||||
|
||||
@fields.depends('currency', 'invoice')
|
||||
def on_change_currency(self):
|
||||
if self.currency:
|
||||
|
@ -148,16 +147,16 @@ class DEX(Workflow, ModelSQL, ModelView):
|
|||
self.invoice_exchange_rate = float(rate)
|
||||
|
||||
def get_amounts(self, name):
|
||||
|
||||
|
||||
amount_for_exchange = []
|
||||
amount_receivable = []
|
||||
if self.lines:
|
||||
for l in self.lines:
|
||||
if l.amount_paid:
|
||||
amount_receivable.append(l.amount_paid)
|
||||
elif l.amount_exchanged:
|
||||
amount_for_exchange.append(l.amount_exchanged)
|
||||
|
||||
for line in self.lines:
|
||||
if line.amount_paid:
|
||||
amount_receivable.append(line.amount_paid)
|
||||
elif line.amount_exchanged:
|
||||
amount_for_exchange.append(line.amount_exchanged)
|
||||
|
||||
if name == 'amount_receivable':
|
||||
return (round(self.invoiced_amount - sum(amount_receivable), 2) if self.invoiced_amount else 0)
|
||||
else:
|
||||
|
@ -193,12 +192,14 @@ class DEXLine(ModelSQL, ModelView):
|
|||
'get_balance')
|
||||
trading_line = fields.Many2One('foreign.exchange.trading_line', 'line',
|
||||
'Trading Line')
|
||||
amount_local_currency = fields.Function(fields.Numeric('Amount Local Currency', digits=(16, 2))
|
||||
,'get_local_amount')
|
||||
amount_local_currency = fields.Function(fields.Numeric(
|
||||
'Amount Local Currency', digits=(16, 2)), 'get_local_amount')
|
||||
profit = fields.Function(fields.Numeric('Profit', digits=(16, 2)),
|
||||
'get_profit')
|
||||
currency=fields.Function(fields.Many2One('currency.currency', 'Currency'), 'get_currency')
|
||||
currency_company=fields.Function(fields.Many2One('currency.currency', ' Company'), 'get_currency')
|
||||
currency = fields.Function(fields.Many2One('currency.currency', 'Currency'),
|
||||
'get_currency')
|
||||
currency_company = fields.Function(fields.Many2One('currency.currency',
|
||||
'Company'), 'get_currency')
|
||||
|
||||
@fields.depends('amount_exchanged', 'amount_paid', 'date')
|
||||
def on_change_exchage_rate(self):
|
||||
|
@ -207,7 +208,7 @@ class DEXLine(ModelSQL, ModelView):
|
|||
ctx = {'date': self.date}
|
||||
|
||||
with Transaction().set_context(ctx):
|
||||
rates= Currency.get_rate([self.currency])
|
||||
rates = Currency.get_rate([self.currency])
|
||||
try:
|
||||
rate = round((1/rates[self.currency.id]), 2)
|
||||
except:
|
||||
|
@ -226,7 +227,8 @@ class DEXLine(ModelSQL, ModelView):
|
|||
|
||||
def get_profit(self, name=None):
|
||||
res = 0
|
||||
if self.amount_exchanged and self.amount_local_currency and self.dex.invoice_exchange_rate:
|
||||
if self.amount_exchanged and self.amount_local_currency and \
|
||||
self.dex.invoice_exchange_rate:
|
||||
res = self.amount_local_currency - (
|
||||
Decimal(self.dex.invoice_exchange_rate) * self.amount_exchanged
|
||||
)
|
||||
|
@ -234,9 +236,9 @@ class DEXLine(ModelSQL, ModelView):
|
|||
|
||||
def get_currency(self, name=None):
|
||||
currency=None
|
||||
if name =='currency' and self.dex.currency:
|
||||
if name == 'currency' and self.dex.currency:
|
||||
currency = self.dex.currency.id
|
||||
elif name=='currency_company' and self.dex.company:
|
||||
elif name == 'currency_company' and self.dex.company:
|
||||
currency = self.dex.company.currency.id
|
||||
return currency
|
||||
|
||||
|
@ -252,7 +254,7 @@ class ForeignExhangeTrading(Workflow, ModelSQL, ModelView):
|
|||
number = fields.Char('Number', states=STATES)
|
||||
exchange_date = fields.Date('Exchange Date')
|
||||
exchange_rate = fields.Float('Exchange Rate')
|
||||
total_exchange = fields.Function(fields.Numeric('Total Exchange', digits=(16,2)),
|
||||
total_exchange = fields.Function(fields.Numeric('Total Exchange', digits=(16,2)),
|
||||
'get_total_exchange')
|
||||
lines = fields.One2Many('foreign.exchange.trading_line', 'exchange', 'Lines')
|
||||
state = fields.Selection([
|
||||
|
@ -305,7 +307,7 @@ class ForeignExhangeTrading(Workflow, ModelSQL, ModelView):
|
|||
@Workflow.transition('confirmed')
|
||||
def confirm(cls, records):
|
||||
cls.set_tranding_dex(records)
|
||||
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('cancelled')
|
||||
|
@ -316,7 +318,7 @@ class ForeignExhangeTrading(Workflow, ModelSQL, ModelView):
|
|||
@ModelView.button_action('farming.wizard_select_lines')
|
||||
def select_lines(cls, records):
|
||||
pass
|
||||
|
||||
|
||||
@classmethod
|
||||
def set_tranding_dex(cls, records):
|
||||
pool = Pool()
|
||||
|
@ -330,14 +332,14 @@ class ForeignExhangeTrading(Workflow, ModelSQL, ModelView):
|
|||
'date': record.exchange_date,
|
||||
'exchange_rate': record.exchange_rate,
|
||||
}
|
||||
for l in record.lines:
|
||||
for line in record.lines:
|
||||
value_ = copy.deepcopy(value)
|
||||
value_.update({
|
||||
'amount_exchanged': l.trading_amount,
|
||||
'dex': l.dex.id,
|
||||
'trading_line': l.id,
|
||||
'amount_exchanged': line.trading_amount,
|
||||
'dex': line.dex.id,
|
||||
'trading_line': line.id,
|
||||
})
|
||||
dex_to_refresh.append(l.dex)
|
||||
dex_to_refresh.append(line.dex)
|
||||
DEXLine.create([value_])
|
||||
DEX.refresh(dex_to_refresh)
|
||||
|
||||
|
@ -353,12 +355,12 @@ class ForeignExhangeTrading(Workflow, ModelSQL, ModelView):
|
|||
lines_to_remove = DEXLine.search([
|
||||
('trading_line', 'in', lines_trading)
|
||||
])
|
||||
dexs = [l.dex for l in lines_to_remove]
|
||||
dexs = [line.dex for line in lines_to_remove]
|
||||
DEXLine.delete(lines_to_remove)
|
||||
DEX.refresh(dexs)
|
||||
|
||||
def get_total_exchange(self, name=None):
|
||||
res = [l.trading_amount for l in self.lines]
|
||||
res = [line.trading_amount for line in self.lines]
|
||||
return sum(res)
|
||||
|
||||
@classmethod
|
||||
|
@ -379,10 +381,10 @@ class ForeignExhangeTradingLine(ModelSQL, ModelView):
|
|||
|
||||
exchange = fields.Many2One('foreign.exchange.trading', 'Exchange',
|
||||
required=True)
|
||||
dex = fields.Many2One('exportation.dex', 'DEX',
|
||||
required=True)
|
||||
dex = fields.Many2One('exportation.dex', 'DEX', required=True)
|
||||
trading_amount = fields.Numeric('Trading Amount', digits=(16, 2))
|
||||
party = fields.Function(fields.Many2One('party.party', 'Party'), 'get_values_dex')
|
||||
party = fields.Function(fields.Many2One('party.party', 'Party'),
|
||||
'get_values_dex')
|
||||
date_dex = fields.Function(fields.Date('Date Dex'), 'get_values_dex')
|
||||
|
||||
@classmethod
|
||||
|
@ -402,7 +404,7 @@ class ForeignExhangeTradingLine(ModelSQL, ModelView):
|
|||
'party': parties,
|
||||
'date_dex': date_dex,
|
||||
}
|
||||
|
||||
|
||||
for key in list(result.keys()):
|
||||
if key not in names:
|
||||
del result[key]
|
||||
|
@ -412,16 +414,16 @@ class ForeignExhangeTradingLine(ModelSQL, ModelView):
|
|||
class SelectLinesAsk(ModelView):
|
||||
'Select Lines Assistant'
|
||||
__name__ = 'farming.select_lines.ask'
|
||||
lines = fields.Many2Many('exportation.dex', None, None,
|
||||
'Dexs', domain=[
|
||||
('state', '=', 'processing')
|
||||
lines = fields.Many2Many('exportation.dex', None, None, 'Dexs', domain=[
|
||||
('state', '=', 'processing')
|
||||
])
|
||||
|
||||
|
||||
class SelectLines(Wizard):
|
||||
'Select Lines'
|
||||
__name__ = 'farming.select_lines'
|
||||
start = StateView('farming.select_lines.ask',
|
||||
start = StateView(
|
||||
'farming.select_lines.ask',
|
||||
'farming.view_search_lines_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Add', 'add_lines', 'tryton-ok', default=True),
|
||||
|
@ -433,11 +435,11 @@ class SelectLines(Wizard):
|
|||
TradingLine = pool.get('foreign.exchange.trading_line')
|
||||
exchange_id = Transaction().context.get('active_id')
|
||||
lines_to_create = []
|
||||
for l in self.start.lines:
|
||||
for line in self.start.lines:
|
||||
value = {
|
||||
'exchange': exchange_id,
|
||||
'dex': l.id,
|
||||
'trading_amount': l.amount_for_exchange
|
||||
'dex': line.id,
|
||||
'trading_amount': line.amount_for_exchange
|
||||
}
|
||||
lines_to_create.append(value)
|
||||
TradingLine.create(lines_to_create)
|
||||
|
@ -452,4 +454,4 @@ class ForeignExhangeTradingReport(CompanyReport):
|
|||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
report_context['company'] = Transaction().context.get('company')
|
||||
return report_context
|
||||
return report_context
|
||||
|
|
15
party.py
15
party.py
|
@ -1,6 +1,6 @@
|
|||
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.model import fields
|
||||
from trytond.model import fields, ModelSQL, ModelView
|
||||
|
||||
|
||||
class Party(metaclass=PoolMeta):
|
||||
|
@ -8,9 +8,20 @@ class Party(metaclass=PoolMeta):
|
|||
carrier = fields.Many2One('party.party', 'Carrier')
|
||||
freight_forwader = fields.Many2One('party.party', 'Freight Forwader')
|
||||
export_route = fields.Char('Export Route', select=True)
|
||||
global_aduana = fields.BigInteger('Global Aduana')
|
||||
customs_globals = fields.One2Many('party.customs_global', 'party',
|
||||
'Custom Globals')
|
||||
|
||||
|
||||
class Company(metaclass=PoolMeta):
|
||||
__name__ = 'company.company'
|
||||
ica_register = fields.Char('ICA Register')
|
||||
|
||||
|
||||
class CustomsGlobal(ModelSQL, ModelView):
|
||||
'Party Customs Global'
|
||||
__name__ = 'party.customs_global'
|
||||
party = fields.Many2One('party.party', 'Party', ondelete='CASCADE',
|
||||
required=True)
|
||||
export_target_city = fields.Many2One('party.city_code', 'Target City',
|
||||
required=True, select=True)
|
||||
global_custom = fields.Char('Global Custom')
|
||||
|
|
12
party.xml
12
party.xml
|
@ -3,6 +3,18 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="party_customs_global_view_tree">
|
||||
<field name="model">party.customs_global</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="name">customs_global_tree</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="party_customs_global_view_form">
|
||||
<field name="model">party.customs_global</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">customs_global_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="party_view_form">
|
||||
<field name="model">party.party</field>
|
||||
<field name="inherit" ref="party.party_view_form"/>
|
||||
|
|
169
production.py
169
production.py
|
@ -1,18 +1,14 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from cgi import print_environ
|
||||
import copy
|
||||
from datetime import timedelta, date, datetime
|
||||
from http import client
|
||||
from datetime import date
|
||||
from shutil import move
|
||||
from unittest import result
|
||||
from sql import Table
|
||||
from trytond.model import fields, ModelView, ModelSQL, Workflow
|
||||
from trytond.model import fields, ModelView, ModelSQL
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.pyson import Eval, If, And, DateTime , Date, Bool, Or
|
||||
from trytond.pyson import Eval
|
||||
from trytond.report import Report
|
||||
from trytond.wizard import Wizard, StateReport, StateView, Button, StateTransition
|
||||
from trytond.wizard import (
|
||||
Wizard, StateReport, StateView, Button, StateTransition)
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
|
@ -61,33 +57,6 @@ class Production(metaclass=PoolMeta):
|
|||
if self.packing_qty and self.packing_uom:
|
||||
return self.packing_qty * self.packing_uom.factor
|
||||
|
||||
#@classmethod
|
||||
#def assign_lots(cls, inputs):
|
||||
# Lot = Pool().get('stock.lot')
|
||||
# transaction = Transaction()
|
||||
# for input in inputs:
|
||||
# ctx = {
|
||||
# 'locations': [input.from_location.id]
|
||||
# }
|
||||
# with transaction.set_context(ctx):
|
||||
# lots = Lot.search([
|
||||
# ('product', '=', input.product.id),
|
||||
# ('quantity', '>', 0)
|
||||
# ], order=[('create_date', 'ASC')])
|
||||
#
|
||||
# # if lots:
|
||||
# # input.save()
|
||||
# remainder = input.quantity
|
||||
# if remainder > 0:
|
||||
# for lot in lots:
|
||||
# if lot.quantity > remainder:
|
||||
# input.lot = lot.id
|
||||
# break
|
||||
# else:
|
||||
# remainder = remainder - lot.quantity
|
||||
# input.quantity = lot.quantity
|
||||
# input.save()
|
||||
|
||||
@classmethod
|
||||
def assign_lot(cls, productions):
|
||||
pool = Pool()
|
||||
|
@ -98,15 +67,17 @@ class Production(metaclass=PoolMeta):
|
|||
if production.state == 'assigned':
|
||||
continue
|
||||
for input in production.inputs:
|
||||
has_origin = MovePhyto.search_read([('origin', '=', str(input))], limit=1)
|
||||
has_origin = MovePhyto.search_read(
|
||||
[('origin', '=', str(input))], limit=1
|
||||
)
|
||||
if input.product.farming and len(has_origin) <= 0:
|
||||
lots = Lot.search([
|
||||
('product', '=', input.product.id),
|
||||
('balance', '>', 0)
|
||||
], order=[('create_date', 'ASC')])
|
||||
required_quantity = input.quantity
|
||||
required_quantity = input.quantity
|
||||
for lot in lots:
|
||||
if required_quantity > 0 :
|
||||
if required_quantity > 0:
|
||||
move_in = 0
|
||||
lot_balance = lot.balance
|
||||
if required_quantity >= lot_balance:
|
||||
|
@ -120,12 +91,11 @@ class Production(metaclass=PoolMeta):
|
|||
move_in = required_quantity
|
||||
required_quantity = 0
|
||||
move_phyto = MovePhyto(
|
||||
lot = lot.id,
|
||||
#stock_move = input.id,
|
||||
origin = (input),
|
||||
date_move = delivery_date,
|
||||
move_in = move_in,
|
||||
move_out = 0
|
||||
lot=lot.id,
|
||||
origin=(input),
|
||||
date_move=delivery_date,
|
||||
move_in=move_in,
|
||||
move_out=0
|
||||
)
|
||||
move_phyto.save()
|
||||
lot.save()
|
||||
|
@ -133,7 +103,9 @@ class Production(metaclass=PoolMeta):
|
|||
break
|
||||
if required_quantity > 0:
|
||||
raise UserError(
|
||||
gettext('farming.msg_missing_quantity_lot', product=input.product.name))
|
||||
gettext(
|
||||
'farming.msg_missing_quantity_lot',
|
||||
product=input.product.name))
|
||||
|
||||
@classmethod
|
||||
def draft(cls, productions):
|
||||
|
@ -165,7 +137,7 @@ class Production(metaclass=PoolMeta):
|
|||
super(Production, cls).run(productions)
|
||||
for pd in productions:
|
||||
if pd.subproductions:
|
||||
cls.run(pd.subproductions)
|
||||
cls.run(pd.subproductions)
|
||||
|
||||
@classmethod
|
||||
def done(cls, productions):
|
||||
|
@ -173,7 +145,7 @@ class Production(metaclass=PoolMeta):
|
|||
for pd in productions:
|
||||
cls.assign_lot([pd])
|
||||
if pd.subproductions:
|
||||
cls.done(pd.subproductions)
|
||||
cls.done(pd.subproductions)
|
||||
|
||||
@classmethod
|
||||
def copy(cls, records, default=None):
|
||||
|
@ -204,9 +176,10 @@ class ProductionTask(ModelView, ModelSQL):
|
|||
performance = fields.Function(fields.Float('Performance', digits=(4, 2)),
|
||||
'get_performance')
|
||||
production = fields.Many2One('production', 'Production', states=STATES)
|
||||
customer = fields.Many2One('party.party','Customer')
|
||||
reference = fields.Many2One('product.product', 'Product', domain=[('type', '=', 'goods')])
|
||||
units = fields.Integer('Units')
|
||||
customer = fields.Many2One('party.party', 'Customer')
|
||||
reference = fields.Many2One('product.product', 'Product',
|
||||
domain=[('type', '=', 'goods')])
|
||||
units = fields.Integer('Units')
|
||||
uom = fields.Many2One('product.uom', 'Uom')
|
||||
factor = fields.Integer('Factor')
|
||||
work_center = fields.Many2One('production.work.center', 'Work Center')
|
||||
|
@ -221,15 +194,10 @@ class ProductionTask(ModelView, ModelSQL):
|
|||
def __setup__(cls):
|
||||
super(ProductionTask, cls).__setup__()
|
||||
cls._buttons.update({
|
||||
'duplicate_wizard': {
|
||||
# 'invisible': Eval('_parent_production', {}).get('state') != 'done',
|
||||
# 'depends': ['_parent_production.state', 'production']
|
||||
},
|
||||
'finishButton': {
|
||||
# 'invisible': Eval('_parent_production', {}).get('state') != 'done',
|
||||
# 'depends': ['_parent_production.state', 'production']
|
||||
}})
|
||||
|
||||
'duplicate_wizard': {},
|
||||
'finishButton': {}
|
||||
})
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def finishButton(cls, records):
|
||||
|
@ -238,7 +206,7 @@ class ProductionTask(ModelView, ModelSQL):
|
|||
rec.state = 'finished'
|
||||
rec.total_time = int((rec.end_time - rec.start_time).seconds / 60)
|
||||
rec.save()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def default_state():
|
||||
return 'draft'
|
||||
|
@ -259,26 +227,25 @@ class ProductionTask(ModelView, ModelSQL):
|
|||
@ModelView.button_action('farming.act_wizard_production_duplicate_task')
|
||||
def duplicate_wizard(cls, records):
|
||||
pass
|
||||
|
||||
|
||||
def get_planned_end_time(self, name):
|
||||
if self.start_time and self.goal:
|
||||
return self.start_time + timedelta(minutes=self.goal)
|
||||
|
||||
@fields.depends('production')
|
||||
def on_change_with_customer(self, name= None):
|
||||
def on_change_with_customer(self, name=None):
|
||||
if self.production:
|
||||
return self.production.customer.id
|
||||
|
||||
|
||||
@fields.depends('production')
|
||||
def on_change_with_reference(self, name= None):
|
||||
def on_change_with_reference(self, name=None):
|
||||
if self.production:
|
||||
return self.production.product.id
|
||||
|
||||
|
||||
@fields.depends('operation', 'quantity')
|
||||
def on_change_with_goal(self, name=None):
|
||||
if self.operation and self.quantity and self.operation.productivity:
|
||||
return int((self.operation.productivity / 60) * self.quantity)
|
||||
return int((self.operation.productivity / 60) * self.quantity)
|
||||
|
||||
@fields.depends('start_time', 'end_time')
|
||||
def on_change_with_total_time(self, name=None):
|
||||
|
@ -313,7 +280,8 @@ class ProductionSummaryStart(ModelView):
|
|||
class ProductionSummary(Wizard):
|
||||
'Purchase Analytic Report'
|
||||
__name__ = 'production.summary'
|
||||
start = StateView('production.summary.start',
|
||||
start = StateView(
|
||||
'production.summary.start',
|
||||
'farming.production_summary_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
|
@ -350,7 +318,7 @@ class ProductionSummaryReport(Report):
|
|||
], order=[('id', 'ASC')])
|
||||
|
||||
inputs = {}
|
||||
types = {'solidos':{}, 'bouquets':{}}
|
||||
types = {'solidos': {}, 'bouquets': {}}
|
||||
styles = []
|
||||
styles_append = styles.append
|
||||
products = []
|
||||
|
@ -372,12 +340,15 @@ class ProductionSummaryReport(Report):
|
|||
product = _inp.product
|
||||
product_id = str(product.id)
|
||||
products_append(product_id)
|
||||
cat_id = str(product.categories[0].id) if product.categories else 'none'
|
||||
cat_name = product.categories[0].name if product.categories else 'none'
|
||||
key = cat_id + '_' + product_id
|
||||
quantity_pending = 0
|
||||
cat = None
|
||||
if product.categories:
|
||||
cat = product.categories[0]
|
||||
cat_id = str(cat.id if cat else 'none')
|
||||
cat_name = cat.name if cat else 'none'
|
||||
key = cat_id + '_' + product_id
|
||||
qty_pending = 0
|
||||
if state != 'done':
|
||||
quantity_pending = _inp.quantity
|
||||
qty_pending = _inp.quantity
|
||||
if key not in inputs.keys():
|
||||
inputs[key] = {
|
||||
'id': product_id,
|
||||
|
@ -386,17 +357,18 @@ class ProductionSummaryReport(Report):
|
|||
'quantity': _inp.quantity,
|
||||
'uom': product.default_uom.name,
|
||||
'solidos': 0,
|
||||
'quantity_pending': quantity_pending
|
||||
'qty_pending': qty_pending
|
||||
}
|
||||
else:
|
||||
qty = inputs[key]['quantity']
|
||||
pend = inputs[key]['quantity_pending']
|
||||
pend = inputs[key]['qty_pending']
|
||||
inputs[key]['quantity'] = qty + _inp.quantity
|
||||
inputs[key]['quantity_pending'] = pend + quantity_pending
|
||||
|
||||
inputs[key]['qty_pending'] = pend + qty_pending
|
||||
|
||||
with Transaction().set_context({'locations': list(locations)}):
|
||||
products = Product.search_read([('id', 'in', products)], fields_names = ['quantity'])
|
||||
products = Product.search_read(
|
||||
[('id', 'in', products)],
|
||||
fields_names=['quantity'])
|
||||
products = {str(p['id']): p for p in products}
|
||||
totals = {
|
||||
'box': {
|
||||
|
@ -423,33 +395,43 @@ class ProductionSummaryReport(Report):
|
|||
for _input in types['solidos'][s].inputs:
|
||||
if _input.uom.symbol == 'STEM':
|
||||
if state != 'done':
|
||||
cat_id = str(_input.product.categories[0].id) if _input.product.categories else 'none'
|
||||
key = cat_id + '_' + str(_input.product.id)
|
||||
cat_id = str(
|
||||
_input.product.categories[0].id) if _input.product.categories else 'none'
|
||||
key = cat_id + '_' + str(_input.product.id)
|
||||
inputs[key]['solidos'] += _input.quantity
|
||||
flag += 1
|
||||
if flag == 1:
|
||||
_solidos.append({'input': _input, 'pcc': _input.production_input})
|
||||
_solidos.append({
|
||||
'input': _input,
|
||||
'pcc': _input.production_input
|
||||
})
|
||||
else:
|
||||
_solidos.append({'input': _input, 'pcc': None})
|
||||
state = 'done' if state == 'done' else 'process'
|
||||
totals = cls.get_values(totals, 'solidos', state, units, quantity )
|
||||
totals = cls.get_values(
|
||||
totals, 'solidos', state, units, quantity)
|
||||
|
||||
_bouquets = []
|
||||
_bouquets = []
|
||||
for b in types['bouquets'].values():
|
||||
flag = 0
|
||||
for _input in b.inputs:
|
||||
if _input.uom.symbol not in ['u', 'STEM']:
|
||||
flag += 1
|
||||
if flag == 1:
|
||||
pcc =_input.production_input
|
||||
pcc = _input.production_input
|
||||
_bouquets.append({'input': _input, 'pcc': pcc})
|
||||
quantity = pcc.quantity
|
||||
units = pcc.units
|
||||
state = pcc.state
|
||||
state = 'done' if state == 'done' else 'process'
|
||||
totals = cls.get_values(totals, 'bouquets', state, units, quantity )
|
||||
totals = cls.get_values(
|
||||
totals, 'bouquets', state, units, quantity)
|
||||
else:
|
||||
_bouquets.append({'input': _input, 'pcc': None, 'factor_packing': _input.quantity/_input.production_input.quantity})
|
||||
_bouquets.append({
|
||||
'input': _input,
|
||||
'pcc': None,
|
||||
'factor_packing': _input.quantity/_input.production_input.quantity
|
||||
})
|
||||
report_context['records'] = records
|
||||
report_context['inputs'] = dict(sorted(inputs.items())).values()
|
||||
report_context['solidos'] = _solidos
|
||||
|
@ -470,6 +452,7 @@ class ProductionSummaryReport(Report):
|
|||
totals['box'][state] += quantity
|
||||
return totals
|
||||
|
||||
|
||||
class MaterialsForecastStart(ModelView):
|
||||
'Materials Forecast Start'
|
||||
__name__ = 'production.materials_forecast.start'
|
||||
|
@ -486,7 +469,8 @@ class MaterialsForecastStart(ModelView):
|
|||
class MaterialsForecast(Wizard):
|
||||
'Materials Forecast'
|
||||
__name__ = 'production.materials_forecast'
|
||||
start = StateView('production.materials_forecast.start',
|
||||
start = StateView(
|
||||
'production.materials_forecast.start',
|
||||
'farming.production_materials_forecast_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
|
@ -605,7 +589,6 @@ class ProductionForceDraft(Wizard):
|
|||
|
||||
def _reset_data(self, prod, delete=None):
|
||||
pool = Pool()
|
||||
Production = pool.get('production')
|
||||
Move_Phyto = pool.get('stock.lot.phyto.move')
|
||||
Lot = pool.get('stock.lot')
|
||||
stock_move = Table('stock_move')
|
||||
|
@ -614,10 +597,6 @@ class ProductionForceDraft(Wizard):
|
|||
lots_to_update = []
|
||||
if not delete:
|
||||
outputs_to_update = [out.id for out in prod.outputs]
|
||||
# if outputs_to_delete:
|
||||
# cursor.execute(*stock_move.delete(
|
||||
# where=stock_move.id.in_(outputs_to_delete)))
|
||||
|
||||
origin_inputs = []
|
||||
inputs_to_update = []
|
||||
|
||||
|
@ -642,15 +621,12 @@ class ProductionForceDraft(Wizard):
|
|||
for rec in prod.inputs:
|
||||
origin_inputs.append(str(rec))
|
||||
inputs_to_update.append(rec.id)
|
||||
|
||||
|
||||
move_phytos = Move_Phyto.search([('origin', 'in', origin_inputs)])
|
||||
lots_to_update.extend(set(m.lot for m in move_phytos))
|
||||
Move_Phyto.delete(move_phytos)
|
||||
moves_to_update = [r.id for r in prod.outputs] + inputs_to_delete
|
||||
if moves_to_update:
|
||||
# cursor.execute(*stock_move.delete(
|
||||
# where=stock_move.id.in_(moves_to_delete) )
|
||||
# )
|
||||
cursor.execute(*stock_move.update(
|
||||
columns=[stock_move.state],
|
||||
values=['draft'],
|
||||
|
@ -659,7 +635,6 @@ class ProductionForceDraft(Wizard):
|
|||
|
||||
prod.state = 'draft'
|
||||
prod.save()
|
||||
# Production.delete([prod])
|
||||
|
||||
if lots_to_update:
|
||||
Lot.recompute_balance(list(set(lots_to_update)))
|
||||
|
|
43
quality.py
43
quality.py
|
@ -90,7 +90,8 @@ class ICACertificate(ModelSQL, ModelView):
|
|||
bool_op = 'AND'
|
||||
else:
|
||||
bool_op = 'OR'
|
||||
return [bool_op,
|
||||
return [
|
||||
bool_op,
|
||||
('number',) + tuple(clause[1:]),
|
||||
('farm',) + tuple(clause[1:]),
|
||||
('party.name',) + tuple(clause[1:]),
|
||||
|
@ -105,10 +106,10 @@ class Phytosanitary(ModelSQL, ModelView):
|
|||
__name__ = "farming.phyto"
|
||||
_rec_name = 'number'
|
||||
number = fields.Char('Number', required=True, select=True)
|
||||
ica = fields.Many2One('farming.quality.ica', 'ICA Certificate', required=True, select=True)
|
||||
ica = fields.Many2One('farming.quality.ica', 'ICA Certificate',
|
||||
required=True, select=True)
|
||||
issue_date = fields.Date('Issue Date', required=True)
|
||||
stock_lots = fields.One2Many('stock.lot', 'phyto', 'Stock Lots')
|
||||
# stocks = fields.One2Many('farming.phyto.stock', 'phyto', 'Stocks')
|
||||
balance = fields.Function(fields.Integer('Balance'), 'get_balance')
|
||||
state = fields.Selection([
|
||||
('active', 'Active'),
|
||||
|
@ -136,12 +137,6 @@ class Phytosanitary(ModelSQL, ModelView):
|
|||
res = [stock.balance for stock in self.stock_lots if stock.balance]
|
||||
return Decimal(sum(res))
|
||||
|
||||
# def get_balance(self, name=None):
|
||||
# res = []
|
||||
# for stock in self.stocks:
|
||||
# res.append(stock.balance)
|
||||
# return sum(res)
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
if clause[1].startswith('!') or clause[1].startswith('not '):
|
||||
|
@ -208,8 +203,8 @@ class PhytoStock(ModelSQL, ModelView):
|
|||
class PhytoStockMove(ModelSQL, ModelView):
|
||||
"Phytosanitary Stock Move"
|
||||
__name__ = "farming.phyto.stock.move"
|
||||
stock = fields.Many2One('farming.phyto.stock', 'Stock Phyto', required=True,
|
||||
ondelete='CASCADE')
|
||||
stock = fields.Many2One('farming.phyto.stock', 'Stock Phyto',
|
||||
required=True, ondelete='CASCADE')
|
||||
date = fields.Date('Date', required=True)
|
||||
move_in = fields.Integer('Move In', required=True)
|
||||
move_out = fields.Integer('Move Out', required=True)
|
||||
|
@ -351,7 +346,9 @@ class ExportationPhyto(Workflow, ModelSQL, ModelView):
|
|||
if input.product.template.farming:
|
||||
moves.append(input)
|
||||
for move in moves:
|
||||
query = move_phyto_table.select(move_phyto_table.id, where=move_phyto_table.origin==str(move))
|
||||
query = move_phyto_table.select(
|
||||
move_phyto_table.id,
|
||||
where=move_phyto_table.origin == str(move))
|
||||
cursor.execute(*query)
|
||||
result = cursor.fetchall()
|
||||
if result:
|
||||
|
@ -370,11 +367,11 @@ class ExportationPhyto(Workflow, ModelSQL, ModelView):
|
|||
}
|
||||
line, = ExLine.create([ex_line])
|
||||
new_phyto_move = {
|
||||
'lot' : move_phyto.lot,
|
||||
'date_move' : export_date,
|
||||
'move_in' : 0,
|
||||
'move_out' : move_phyto.move_in,
|
||||
'origin' : str(line)
|
||||
'lot': move_phyto.lot,
|
||||
'date_move': export_date,
|
||||
'move_in': 0,
|
||||
'move_out': move_phyto.move_in,
|
||||
'origin': str(line)
|
||||
}
|
||||
new_id_phyto, = MovePhyto.create([new_phyto_move])
|
||||
line.phyto_moves = new_id_phyto.id
|
||||
|
@ -416,7 +413,7 @@ class ExportationPhyto(Workflow, ModelSQL, ModelView):
|
|||
self.write([self], {'number': number})
|
||||
|
||||
def get_total_quantity(self, name=None):
|
||||
return sum(l.quantity for l in self.lines)
|
||||
return sum(line.quantity for line in self.lines)
|
||||
|
||||
|
||||
class ExportationPhytoLine(ModelSQL, ModelView):
|
||||
|
@ -425,15 +422,11 @@ class ExportationPhytoLine(ModelSQL, ModelView):
|
|||
ica_register = fields.Many2One('farming.quality.ica', 'ICA Register',
|
||||
required=True)
|
||||
phyto = fields.Many2One('exportation.phyto', 'Phyto')
|
||||
# in_phyto = fields.Many2One('farming.phyto', 'In Phyto', domain=[('ica', '=', Eval('ica_register'))])
|
||||
quantity = fields.Integer('Quantity')
|
||||
phyto_moves = fields.Many2One('stock.lot.phyto.move', 'origin', 'Phyto Move',
|
||||
domain=[('lot.phyto.ica', '=', Eval('ica_register'))], ondelete="CASCADE")
|
||||
# phyto_move = fields.Many2One('farming.phyto.stock.move', 'Phyto Move',
|
||||
# states = {'required': False}, ondelete='CASCADE')
|
||||
manual = fields.Boolean('Manual')
|
||||
|
||||
|
||||
@classmethod
|
||||
def delete(cls, records):
|
||||
StockMove = Pool().get('stock.lot.phyto.move')
|
||||
|
@ -461,7 +454,8 @@ class PhytoMovesStart(ModelView):
|
|||
class PhytoMoves(Wizard):
|
||||
'Phyto Moves'
|
||||
__name__ = 'farming.phyto_moves'
|
||||
start = StateView('farming.phyto_moves.start',
|
||||
start = StateView(
|
||||
'farming.phyto_moves.start',
|
||||
'farming.phyto_moves_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
|
@ -555,7 +549,8 @@ class PurchaseMonitoringStart(ModelView):
|
|||
class PurchaseMonitoring(Wizard):
|
||||
'Purchase Monitoring'
|
||||
__name__ = 'farming.purchase_monitoring'
|
||||
start = StateView('farming.purchase_monitoring.start',
|
||||
start = StateView(
|
||||
'farming.purchase_monitoring.start',
|
||||
'farming.purchase_monitoring_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
|
|
79
sale.py
79
sale.py
|
@ -6,7 +6,8 @@ from sql import Table
|
|||
from decimal import Decimal
|
||||
|
||||
from trytond.model import fields, ModelSQL, ModelView
|
||||
from trytond.wizard import Wizard, StateView, Button, StateTransition, StateReport
|
||||
from trytond.wizard import (
|
||||
Wizard, StateView, Button, StateTransition, StateReport)
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
|
@ -42,6 +43,9 @@ class Sale(metaclass=PoolMeta):
|
|||
aged = fields.Function(fields.Integer('Aged'), 'get_aged')
|
||||
total_amount_ref = fields.Function(fields.Numeric('Total Amount Ref.',
|
||||
digits=(6, 2)), 'get_total_amount_ref')
|
||||
custom_global = fields.Many2One('party.customs_global', domain=[
|
||||
('party', '=', Eval('party'))
|
||||
])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -281,7 +285,8 @@ class SaleLine(metaclass=PoolMeta):
|
|||
@fields.depends('kits', 'product', 'description')
|
||||
def on_change_kits(self, name=None):
|
||||
if self.product and self.kits:
|
||||
string_ = [ki.product.template.name
|
||||
string_ = [
|
||||
ki.product.template.name
|
||||
for ki in self.kits if ki.product and ki.product.template.farming]
|
||||
if not string_:
|
||||
return
|
||||
|
@ -390,7 +395,8 @@ class GroupingSalesStart(ModelView):
|
|||
class GroupingSales(Wizard):
|
||||
'Grouping Sales'
|
||||
__name__ = 'sale.grouping_sales'
|
||||
start = StateView('sale.grouping_sales.start',
|
||||
start = StateView(
|
||||
'sale.grouping_sales.start',
|
||||
'farming.grouping_sales_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Ok', 'accept', 'tryton-ok', default=True),
|
||||
|
@ -489,7 +495,11 @@ class SaleChangeProcessing(Wizard):
|
|||
sale, = Sale.browse([sale_id])
|
||||
if sale.state in ['done', 'processing'] and sale.id:
|
||||
cursor.execute(*sale_table.update(
|
||||
columns=[sale_table.state, sale_table.untaxed_amount_cache, sale_table.tax_amount_cache, sale_table.total_amount_cache],
|
||||
columns=[
|
||||
sale_table.state,
|
||||
sale_table.untaxed_amount_cache,
|
||||
sale_table.tax_amount_cache,
|
||||
sale_table.total_amount_cache],
|
||||
values=['processing', 0, 0, 0],
|
||||
where=sale_table.id == sale.id)
|
||||
)
|
||||
|
@ -504,7 +514,6 @@ class PortfolioDetailedStart(ModelView):
|
|||
parties = fields.Many2Many('party.party', None, None, 'Parties')
|
||||
type = fields.Selection([
|
||||
('out', 'Customer'),
|
||||
# ('in', 'Supplier'),
|
||||
], 'Type', required=True)
|
||||
|
||||
@staticmethod
|
||||
|
@ -519,7 +528,8 @@ class PortfolioDetailedStart(ModelView):
|
|||
class PortfolioDetailed(Wizard):
|
||||
'Portfolio Detailed'
|
||||
__name__ = 'farming.portfolio_detailed'
|
||||
start = StateView('farming.portfolio_detailed.start',
|
||||
start = StateView(
|
||||
'farming.portfolio_detailed.start',
|
||||
'farming.print_sale_portfolio_detailed_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
|
@ -545,7 +555,6 @@ class PortfolioDetailedReport(Report):
|
|||
|
||||
@classmethod
|
||||
def get_domain_inv(cls, dom_sales, data):
|
||||
states = ['done']
|
||||
dom_sales.append([
|
||||
('company', '=', data['company']),
|
||||
])
|
||||
|
@ -569,14 +578,14 @@ class PortfolioDetailedReport(Report):
|
|||
Sale = pool.get('sale.sale')
|
||||
dom_sales = []
|
||||
dom_sales = cls.get_domain_inv(dom_sales, data)
|
||||
sales = Sale.search(dom_sales,
|
||||
sales = Sale.search(
|
||||
dom_sales,
|
||||
order=[('party.name', 'ASC'), ('shipping_date', 'ASC')]
|
||||
)
|
||||
salesmans = {}
|
||||
for sale in sales:
|
||||
pay_to_date = []
|
||||
if data['to_date']:
|
||||
move_lines_paid = []
|
||||
for line in sale.payments:
|
||||
if line.date <= data['to_date']:
|
||||
pay_to_date.append(line.amount)
|
||||
|
@ -584,12 +593,14 @@ class PortfolioDetailedReport(Report):
|
|||
amount_to_pay = sale.total_amount - sum(pay_to_date)
|
||||
else:
|
||||
amount_to_pay = sale.residual_amount
|
||||
pay_to_date = [pay.amount for pay in sale.payments if pay.amount]
|
||||
pay_to_date = [
|
||||
pay.amount for pay in sale.payments if pay.amount]
|
||||
|
||||
if sale.total_amount == sum(pay_to_date):
|
||||
continue
|
||||
|
||||
if 'field_salesman' in data.keys() and data['field_salesman'] and sale.salesman:
|
||||
if 'field_salesman' in data.keys() and \
|
||||
data['field_salesman'] and sale.salesman:
|
||||
if sale.salesman.id not in salesmans.keys():
|
||||
salesmans[sale.salesman.id] = {
|
||||
'salesman': sale.salesman.party.full_name,
|
||||
|
@ -617,11 +628,12 @@ class PortfolioDetailedReport(Report):
|
|||
'total_amount_to_pay': [],
|
||||
}
|
||||
|
||||
party_key = salesmans[salesman]['parties'][sale.party.id]
|
||||
salesmans[salesman]['total_invoices'].append(sale.total_amount)
|
||||
salesmans[salesman]['total_amount_to_pay'].append(amount_to_pay)
|
||||
salesmans[salesman]['parties'][sale.party.id]['invoices'].append(sale)
|
||||
salesmans[salesman]['parties'][sale.party.id]['total_invoices'].append(sale.total_amount)
|
||||
salesmans[salesman]['parties'][sale.party.id]['total_amount_to_pay'].append(amount_to_pay)
|
||||
party_key['invoices'].append(sale)
|
||||
party_key['total_invoices'].append(sale.total_amount)
|
||||
party_key['total_amount_to_pay'].append(amount_to_pay)
|
||||
|
||||
report_context['records'] = salesmans
|
||||
report_context['data'] = data
|
||||
|
@ -638,7 +650,8 @@ class AduanaDetailedStart(ModelView):
|
|||
class AduanaDetailed(Wizard):
|
||||
'Aduana Detailed'
|
||||
__name__ = 'farming.aduana_detailed'
|
||||
start = StateView('farming.aduana_detailed.start',
|
||||
start = StateView(
|
||||
'farming.aduana_detailed.start',
|
||||
'farming.aduana_detailed_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
|
@ -661,13 +674,12 @@ class AduanaDetailedReport(Report):
|
|||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
|
||||
pool = Pool()
|
||||
Sale = pool.get('sale.sale')
|
||||
sales = Sale.search( ('shipping_date', '=', data['date']))
|
||||
reportSales = {}
|
||||
sales = Sale.search(('shipping_date', '=', data['date']))
|
||||
report_sales = {}
|
||||
for sale in sales:
|
||||
if sale.number:
|
||||
if sale.number:
|
||||
total_weight = 0
|
||||
for line in sale.lines:
|
||||
if line.packing_uom.symbol == 'EB':
|
||||
|
@ -677,21 +689,20 @@ class AduanaDetailedReport(Report):
|
|||
elif line.packing_uom.symbol == 'HB':
|
||||
total_weight = total_weight + (line.packing_qty * 8.5)
|
||||
|
||||
reportSales[sale.number] = {
|
||||
report_sales[sale.number] = {
|
||||
'client': sale.party.name,
|
||||
'nit' : sale.carrier.id_number,
|
||||
'guia' : sale.mawb,
|
||||
'global' : sale.party.global_aduana,
|
||||
'invoice' : sale.number,
|
||||
'code' : '0001',
|
||||
'product' : 'Hidrangea',
|
||||
'units' : sale.unit_qty,
|
||||
'pieces' : sale.packing_qty,
|
||||
'weight' : total_weight,
|
||||
'total' : sale.total_amount,
|
||||
'license_plate' : 'WHO-265',
|
||||
'nit': sale.carrier.id_number,
|
||||
'guia': sale.mawb,
|
||||
'global': sale.custom_global and sale.custom_global.global_custom,
|
||||
'invoice': sale.number,
|
||||
'code': '0001',
|
||||
'product': 'Hidrangea',
|
||||
'units': sale.unit_qty,
|
||||
'pieces': sale.packing_qty,
|
||||
'weight': total_weight,
|
||||
'total': sale.total_amount,
|
||||
'license_plate': 'WHO-265',
|
||||
}
|
||||
report_context['records'] = reportSales.values()
|
||||
|
||||
return report_context
|
||||
report_context['records'] = report_sales.values()
|
||||
|
||||
return report_context
|
||||
|
|
41
stock.py
41
stock.py
|
@ -1,10 +1,5 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from dataclasses import field
|
||||
from datetime import date
|
||||
from itertools import product
|
||||
from operator import index
|
||||
from shutil import move
|
||||
from trytond.model import fields, ModelView, ModelSQL
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.pyson import Eval
|
||||
|
@ -19,10 +14,9 @@ class StockLot(metaclass=PoolMeta):
|
|||
quantity_purchase = fields.Float('Quantity Purchase',
|
||||
digits=(16, Eval('unit_digits', 2)))
|
||||
arrival_date = fields.Date('Arrival Date')
|
||||
balance = fields.Float('Balance',
|
||||
digits=(16, Eval('unit_digits', 2)))
|
||||
balance_export = fields.Float('Balance Export',
|
||||
digits=(16, Eval('unit_digits', 2)))
|
||||
balance = fields.Float('Balance', digits=(16, Eval('unit_digits', 2)))
|
||||
balance_export = fields.Float('Balance Export', digits=(16,
|
||||
Eval('unit_digits', 2)))
|
||||
location = fields.Char('Location')
|
||||
|
||||
@staticmethod
|
||||
|
@ -40,8 +34,8 @@ class StockLot(metaclass=PoolMeta):
|
|||
@fields.depends('phyto', 'number')
|
||||
def on_change_phyto(self):
|
||||
if self.phyto:
|
||||
self.number = self.phyto.ica.code + '-' + self.phyto.number
|
||||
|
||||
self.number = self.phyto.ica.code + '-' + self.phyto.number
|
||||
|
||||
@fields.depends('phyto_move', 'balance', 'balance_export')
|
||||
def on_change_phyto_move(self, name=None):
|
||||
data = self.get_balance(self)
|
||||
|
@ -56,21 +50,18 @@ class StockLot(metaclass=PoolMeta):
|
|||
balance_export = move_in - move_out
|
||||
return {'balance': balance, 'balance_export': balance_export}
|
||||
|
||||
|
||||
|
||||
class PythoMove(ModelSQL, ModelView):
|
||||
'Phyto Move'
|
||||
__name__ = 'stock.lot.phyto.move'
|
||||
lot = fields.Many2One('stock.lot', 'Lot', select=True,
|
||||
ondelete='CASCADE')
|
||||
exportation_phyto = fields.Many2One('exportation.phyto', 'Exportation Phyto', select=True)
|
||||
#subproduction = fields.Many2One('production', 'Sub-Production')
|
||||
#stock_move = fields.Many2One('stock.move', 'Moves Stock')
|
||||
exportation_phyto = fields.Many2One(
|
||||
'exportation.phyto', 'Exportation Phyto', select=True)
|
||||
origin = fields.Reference('Origin', selection='get_origin')
|
||||
date_move = fields.Date("Date Move")
|
||||
move_in = fields.Float('Move In',
|
||||
digits=(16, Eval('unit_digits', 2)))
|
||||
move_out = fields.Float('Move out',
|
||||
digits=(16, Eval('unit_digits', 2)))
|
||||
move_in = fields.Float('Move In', digits=(16, Eval('unit_digits', 2)))
|
||||
move_out = fields.Float('Move out', digits=(16, Eval('unit_digits', 2)))
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
|
@ -83,7 +74,7 @@ class PythoMove(ModelSQL, ModelView):
|
|||
get_name = Model.get_name
|
||||
models = cls._get_origin()
|
||||
return [(None, '')] + [(m, get_name(m)) for m in models]
|
||||
|
||||
|
||||
def get_rec_name(self, name=None):
|
||||
if self.lot:
|
||||
return self.lot.number
|
||||
|
@ -108,13 +99,13 @@ class StockMove(metaclass=PoolMeta):
|
|||
}
|
||||
farming = fields.Boolean('Farming')
|
||||
original_qty = fields.Float('Qty Original', states=STATES)
|
||||
#move_phyto = fields.One2Many('stock.lot.phyto.move', 'stock_move', 'Move Phyto')
|
||||
production = fields.Many2One("production", "Production")
|
||||
style = fields.Many2One('product.style', 'Style')
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
return super(StockMove, cls)._get_origin() + ['production', 'farming.crop.activity']
|
||||
return super(StockMove, cls)._get_origin() + [
|
||||
'production', 'farming.crop.activity']
|
||||
|
||||
|
||||
class ShipmentIn(metaclass=PoolMeta):
|
||||
|
@ -132,10 +123,10 @@ class ShipmentIn(metaclass=PoolMeta):
|
|||
moves = []
|
||||
if shipment.phyto:
|
||||
number_lot = shipment.phyto.ica.code + '-' + shipment.phyto.number
|
||||
id_phyto = shipment.phyto.id
|
||||
for move in shipment.incoming_moves:
|
||||
id_phyto = shipment.phyto.id
|
||||
for move in shipment.incoming_moves:
|
||||
if not move.product.template.farming:
|
||||
continue
|
||||
continue
|
||||
lot, = Lot.create([{
|
||||
'number' : number_lot,
|
||||
'product' : move.product.id,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.31
|
||||
version=6.0.32
|
||||
depends:
|
||||
party
|
||||
company
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="export_target_city"/>
|
||||
<field name="export_target_city"/>
|
||||
<label name="global_custom"/>
|
||||
<field name="global_custom"/>
|
||||
</form>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="export_target_city" expand="1"/>
|
||||
<field name="global_custom" expand="1"/>
|
||||
</tree>
|
|
@ -6,10 +6,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<label name="carrier"/>
|
||||
<field name="carrier"/>
|
||||
<label name="freight_forwader"/>
|
||||
<field name="freight_forwader"/>
|
||||
<label name="export_route"/>
|
||||
<field name="export_route"/>
|
||||
<label name="global_aduana"/>
|
||||
<field name="global_aduana"/>
|
||||
<field name="freight_forwader"/>>
|
||||
<field name="customs_globals" colspan="4"/>
|
||||
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
|
@ -25,6 +25,8 @@ copyright notices and license terms. -->
|
|||
<field name="export_target_city"/>
|
||||
<label name="export_route"/>
|
||||
<field name="export_route"/>
|
||||
<label name="custom_global"/>
|
||||
<field name="custom_global"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
Loading…
Reference in New Issue