Delete unused function.

Add new UserError.
Add "on_change_*" calls.
FIX depends.

Task #045017
This commit is contained in:
Juanjo Garcia 2022-04-19 10:57:06 +02:00
parent b32a88ab95
commit 94733ffa1e
3 changed files with 10 additions and 42 deletions

View File

@ -42,5 +42,8 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="msg_cant_active_contract">
<field name="text">The contract "%(contract)s" cant be activated because the parcel "%(parcel)s" is in another active contract.</field>
</record>
<record model="ir.message" id="msg_location_no_configured">
<field name="text">The weighing center "%(center)s" dont have a to location configured.</field>
</record>
</data>
</tryton>

View File

@ -12,7 +12,7 @@ depends:
purchase_contract
production
stock
invoice_line_standalone
account_invoice_line_standalone
xml:
plot.xml
party.xml

View File

@ -320,12 +320,14 @@ class Weighing(Workflow, ModelSQL, ModelView):
# Create Move
move.from_location = supplier_location[0]
#TODO: cehck if we have to_location
if not weighing.weighing_center.to_location:
raise UserError(
gettext('agronomics.msg_location_no_configured',
center=weighing.weighing_center.name))
move.to_location = weighing.weighing_center.to_location
move.product = weighing.product_created
move.uom = weighing.product_created.template.default_uom
move.unit_price = weighing.product_created.template.list_price
# TODO: if we dont have any quantity use 0 or raise an error?
move.quantity = weighing.netweight or 0
weighing.inventory_move = move
@ -432,39 +434,6 @@ class Weighing(Workflow, ModelSQL, ModelView):
def draft(cls, weighings):
pass
def get_invoice(self, party):
pool = Pool()
Journal = pool.get('account.journal')
Invoice = pool.get('account.invoice')
Company = pool.get('company.company')
context = Transaction().context
invoices = Invoice.search([
('party', '=', party),
('state', '=', 'draft'),
('type', '=', 'in')])
if invoices:
invoice = invoices[0]
if not invoices:
journals = Journal.search([
('type', '=', 'expense'),
], limit=1)
if journals:
journal, = journals
else:
journal = None
invoice = Invoice()
invoice.company = Company(context['company'])
invoice.type = 'in'
invoice.journal = journal
invoice.party = party
invoice.invoice_address = party.address_get(type='invoice')
invoice.currency = Company(context['company']).currency
invoice.account = party.account_payable_used
invoice.payment_term = party.supplier_payment_term
return invoice
@classmethod
@Workflow.transition('done')
def done(cls, weighings):
@ -506,10 +475,9 @@ class Weighing(Workflow, ModelSQL, ModelView):
Company(context['company']).currency)
invoice_line.company = Company(context['company'])
invoice_line.description = ''
invoice_line.quantity = weighing.netweight or 0
invoice_line.unit = (
weighing.product_created.template.default_uom)
invoice_line.product = weighing.product_created
invoice_line.on_change_product()
invoice_line.quantity = weighing.netweight or 0
unit_price = Product.get_purchase_price(
[weighing.product_created],
@ -525,9 +493,6 @@ class Weighing(Workflow, ModelSQL, ModelView):
unit_price = unit_price
invoice_line.unit_price = unit_price
cost_price += unit_price
#invoice_line.taxes =
invoice_line.account = (
weighing.product_created.account_expense_used)
weighing_invoice = WeighingInvoiceLine(
weighing=weighing,