本文整理汇总了Python中stoqlib.domain.sale.Sale.add_sellable方法的典型用法代码示例。如果您正苦于以下问题:Python Sale.add_sellable方法的具体用法?Python Sale.add_sellable怎么用?Python Sale.add_sellable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.sale.Sale
的用法示例。
在下文中一共展示了Sale.add_sellable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_one
# 需要导入模块: from stoqlib.domain.sale import Sale [as 别名]
# 或者: from stoqlib.domain.sale.Sale import add_sellable [as 别名]
def process_one(self, data, fields, store):
person = store.find(Person, name=data.branch_name).one()
if person is None or person.branch is None:
raise ValueError(u"%s is not a valid branch" % (
data.branch_name, ))
branch = person.branch
person = store.find(Person, name=data.client_name).one()
if person is None or person.client is None:
raise ValueError(u"%s is not a valid client" % (
data.client_name, ))
client = person.client
person = store.find(Person, name=data.salesperson_name).one()
if person is None or person.salesperson is None:
raise ValueError(u"%s is not a valid sales person" % (
data.salesperson_name, ))
salesperson = person.salesperson
group = PaymentGroup(store=store)
sale = Sale(client=client,
open_date=self.parse_date(data.open_date),
coupon_id=int(data.coupon_id),
invoice_number=int(data.coupon_id),
salesperson=salesperson,
branch=branch,
cfop=sysparam(store).DEFAULT_SALES_CFOP,
group=group,
store=store)
total_price = 0
for product in self.parse_multi(Product, data.product_list, store):
sale.add_sellable(product.sellable)
total_price += product.sellable.price
sale.order()
method = PaymentMethod.get_by_name(store, data.payment_method)
method.create_inpayment(group, branch, total_price,
self.parse_date(data.due_date))
sale.confirm()
#XXX: The payments are paid automatically when a sale is confirmed.
# So, we will change all the payment paid_date to the same date
# as open_date, then we can test the reports properly.
for payment in sale.payments:
if payment.is_paid():
p = store.fetch(payment)
p.paid_date = self.parse_date(data.open_date)
示例2: _create_sale
# 需要导入模块: from stoqlib.domain.sale import Sale [as 别名]
# 或者: from stoqlib.domain.sale.Sale import add_sellable [as 别名]
def _create_sale(self, store):
user = api.get_current_user(store)
branch = api.get_current_branch(store)
salesperson = user.person.salesperson
cfop_id = api.sysparam.get_object_id('DEFAULT_SALES_CFOP')
nature = api.sysparam.get_string('DEFAULT_OPERATION_NATURE')
group = PaymentGroup(store=store)
sale = Sale(
store=store,
branch=branch,
salesperson=salesperson,
group=group,
cfop_id=cfop_id,
coupon_id=None,
operation_nature=nature)
if self._delivery:
sale.client = store.fetch(self._delivery.client)
sale.storeporter = store.fetch(self._delivery.transporter)
delivery = Delivery(
store=store,
address=store.fetch(self._delivery.address),
transporter=store.fetch(self._delivery.transporter),
)
else:
delivery = None
sale.client = self._suggested_client
for fake_sale_item in self.sale_items:
sale_item = sale.add_sellable(
store.fetch(fake_sale_item.sellable),
price=fake_sale_item.price,
quantity=fake_sale_item.quantity,
quantity_decreased=fake_sale_item.quantity_decreased,
batch=store.fetch(fake_sale_item.batch))
sale_item.notes = fake_sale_item.notes
sale_item.estimated_fix_date = fake_sale_item.estimated_fix_date
if delivery and fake_sale_item.deliver:
delivery.add_item(sale_item)
elif delivery and fake_sale_item == self._delivery_item:
delivery.service_item = sale_item
return sale